VC++无标题窗口以及控件拖动的方法(修正)
来源:互联网 发布:遗传算法优化svm参数 编辑:程序博客网 时间:2024/05/17 08:37
无标题窗口拖动:
方法一:直接在OnNcHitTest中虚拟发送HTCAPTION消息
- UINT CMainFrame::OnNcHitTest(CPoint point)
- {
- RECT rectWindows, rectClient;
- this->GetWindowRect(&rectWindows);
- this->GetClientRect(&rectClient);
- if (point.y > rectWindows.top && point.y < rectWindows.top + 25)
- {
- return HTCAPTION;//标题栏形式
- }
- else
- {
- return CFrameWnd::OnNcHitTest(point);
- }
- }
UINT CMainFrame::OnNcHitTest(CPoint point) { RECT rectWindows, rectClient; this->GetWindowRect(&rectWindows); this->GetClientRect(&rectClient); if (point.y > rectWindows.top && point.y < rectWindows.top + 25) { return HTCAPTION;//标题栏形式 } else { return CFrameWnd::OnNcHitTest(point); }}
方法二:直接在OnLButtonDown中虚拟发送WM_NCLBUTTONDOWN,HTCAPTION消息
- void CMyDlg::OnLButtonDown(UINT nFlags, CPoint point)
- {
- if (point.y < 26)
- PostMessage(WM_NCLBUTTONDOWN,HTCAPTION,MAKELPARAM(point.x,point.y));
- CDialog::OnLButtonDown(nFlags, point);
- }
void CMyDlg::OnLButtonDown(UINT nFlags, CPoint point) {if (point.y < 26)PostMessage(WM_NCLBUTTONDOWN,HTCAPTION,MAKELPARAM(point.x,point.y));CDialog::OnLButtonDown(nFlags, point);}
方法三:通过在OnMouseMove中手动进行处理
- void CMyDlg::OnMouseMove(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- static CPoint PrePoint = CPoint(0, 0);
- if(MK_LBUTTON == nFlags)
- {
- if(point != PrePoint)
- {
- CPoint ptTemp = point - PrePoint;
- CRect rcWindow;
- GetWindowRect(&rcWindow);
- rcWindow.OffsetRect(ptTemp.x, ptTemp.y);
- MoveWindow(&rcWindow);
- return ;
- }
- }
- PrePoint = point;
- CDialog::OnMouseMove(nFlags, point);
- }
void CMyDlg::OnMouseMove(UINT nFlags, CPoint point){ // TODO: Add your message handler code here and/or call default static CPoint PrePoint = CPoint(0, 0); if(MK_LBUTTON == nFlags) { if(point != PrePoint) { CPoint ptTemp = point - PrePoint; CRect rcWindow; GetWindowRect(&rcWindow); rcWindow.OffsetRect(ptTemp.x, ptTemp.y); MoveWindow(&rcWindow); return ; } } PrePoint = point; CDialog::OnMouseMove(nFlags, point);}
控件拖动:
控件拖动只能采用上述的第三种方法
- VC++无标题窗口以及控件拖动的方法(修正)
- VC++无标题窗口以及控件拖动的方法(修正)
- VC++无标题窗口以及控件拖动的方法(修正)
- VC++无标题窗口以及控件拖动的方法(修正)
- VC++无标题窗口以及控件拖动的方法
- VC++无标题窗口以及控件拖动的方法
- VC++无标题窗口以及控件拖动的方法,MFC中的对话框怎么拖动不了
- 拖动无标题窗口的方法
- 无标题窗口的拖动
- 实现无标题窗口的拖动
- 实现拖动无标题窗口的5种方法
- MFC:拖动无标题窗口的两种方法
- delphi实现拖动无标题窗口的5种方法
- MFC:拖动无标题窗口的三种方法
- 拖动无标题窗口
- 无标题窗口拖动
- 无标题窗口拖动
- duilib 无标题窗口拖动
- 开源成为一种趋势,iMatrix平台强势归来!
- ArcGIS License Manager 静默授权命令摘录
- plsql-聚簇表初解
- libnl3安装及使用
- A Security-focused HTTP Primer---http://danielmiessler.com/popular/
- VC++无标题窗口以及控件拖动的方法(修正)
- 怎样学会理财?
- HDU--1251 -- 统计难题 [字典树基本应用] [用数组事先分配空间以节约时间]
- CodeForces 178B1 - Greedy Merchants tarjan求双联通分量+tarjan离线求最近公共祖先
- ibasefilter 转
- mysql的安装目录下找不到data目录的解决方法
- Apache Pig的一些基础概念及用法总结(1)
- mssql查询特定表&列是否存在
- poj 3414 搜索