关于CWnd::MoveWindow()的理解?

小竹z 2012-06-05 10:31:56
我创建了一个单文档程序,并添加了一个菜单响应事件,事件创建了一个非模态的对话框,并显示在单文档程序的左下角,我是在CMainFrame类里面处理的菜单响应事件,显示对话框前,调用GetWindowRect(&rect)得到单文档程序的位置,然后移动pColourDlg->MoveWindow(rect.left,rect.bottom,rect.Width()/2,70);对话框刚好在左边底部显示,左边与单文档程序左边缘对齐,我的疑问是movewindow函数中的坐标应该是相对于父窗口的,创建这个对话框时指定其父窗口为CMainFrame,且rect.left并不等于0,为什么对话框会与单文档左边对齐,而不是应该偏移rect.left的位置吗?
...全文
279 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
小竹z 2012-06-09
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 的回复:]
。。。按钮是child控件,movewindow的时候都是父窗口的客户区坐标。非模态窗口默认是POP-up风格,是个top-level窗口,movewindow的都是屏幕坐标。

什么是个child窗口,就是这个窗口只能在父窗口内移动。你一个pop-UP的窗口是可以拖放到屏幕的任何位置
[/Quote]
明白了~谢谢先
dahaiI0 2012-06-08
  • 打赏
  • 举报
回复
。。。按钮是child控件,movewindow的时候都是父窗口的客户区坐标。非模态窗口默认是POP-up风格,是个top-level窗口,movewindow的都是屏幕坐标。

什么是个child窗口,就是这个窗口只能在父窗口内移动。你一个pop-UP的窗口是可以拖放到屏幕的任何位置
就叫我海 2012-06-07
  • 打赏
  • 举报
回复
刚才试了下.. 确实是这样的,, 好像是坐标是相对于屏幕的....
dahaiI0 2012-06-07
  • 打赏
  • 举报
回复
你的对话框是个pop-up窗口吧
诶呦 2012-06-07
  • 打赏
  • 举报
回复
两种情况:For a top-level CWnd object 或者 For a child CWnd object
定或者子
小竹z 2012-06-07
  • 打赏
  • 举报
回复
新建了一个对话框,拖了一个button控件,用同样的方式,结果button却是相对于对话框~看来单文档和对话框程序还是有区别的.
小竹z 2012-06-06
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
Remarks

Changes the position and dimensions.

For a top-level CWnd object, the x and y parameters are relative to the upper-left corner of the screen. For a child CWnd object, they are relative ……
[/Quote]
但是我觉得创建这个非模态对话框,其父窗口应该是CMainFrame哇,它不应该是一个顶窗口,应该是一个子窗口.
小竹z 2012-06-06
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
Remarks

Changes the position and dimensions.

For a top-level CWnd object, the x and y parameters are relative to the upper-left corner of the screen. For a child CWnd object, they are relative ……
[/Quote]
但是我觉得创建这个非模态对话框,其父窗口应该是CMainFrame哇,它不应该是一个顶窗口,应该是一个子窗口.
诶呦 2012-06-06
  • 打赏
  • 举报
回复
Remarks

Changes the position and dimensions.

For a top-level CWnd object, the x and y parameters are relative to the upper-left corner of the screen. For a child CWnd object, they are relative to the upper-left corner of the parent window’s client area.

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧