MoveWindow的问题:

electri 2010-05-04 10:43:51
一个对话框程序,放了一个文本框IDC_OUTPUT_PATH,在一个按钮的事件中写如下的代码,对话框就移动位置了,这是为什么?
CRect rect1;
GetDlgItem(IDC_OUTPUT_PATH)->GetClientRect(&rect1);
GetDlgItem(IDC_OUTPUT_PATH)->ClientToScreen(&rect1);
GetDlgItem(IDC_OUTPUT_PATH)->MoveWindow(&rect1);
...全文
96 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangli820 2010-05-12
  • 打赏
  • 举报
回复
楼主啊,你自己调试一下吧,注释了其中的一条语句,逐个看
向立天 2010-05-12
  • 打赏
  • 举报
回复
您好
我是本版版主
此帖已多日无人关注
请您及时结帖
如您认为问题没有解决可按无满意结帖处理
另外本版设置了疑难问题汇总帖
并已在版面置顶
相关规定其帖子中有说明
您可以根据规定提交您帖子的链接
如您目前不想结帖只需回帖说明
我们会删除此结帖通知

见此回复三日内无回应
我们将强制结帖
相关规定详见界面界面版关于版主结帖工作的具体办法
Eleven 2010-05-04
  • 打赏
  • 举报
回复
GetDlgItem(IDC_OUTPUT_PATH)->MoveWindow(&rect1);你这个是移动文本框,何来移动对话框?你确定没有调用MoveWindow或者SetWindowPos来移动对话框???
wade_2003 2010-05-04
  • 打赏
  • 举报
回复
GetDlgItem(IDC_OUTPUT_PATH)->MoveWindow(&rect1);这个不起作用吗?
快乐鹦鹉 2010-05-04
  • 打赏
  • 举报
回复
你没有调用对话框的MoveWindow啊,怎么会移动呢
electri 2010-05-04
  • 打赏
  • 举报
回复
void GetClientRect( LPRECT lpRect ) const;
lpRect:Points to a RECT structure or a CRect object to receive the client coordinates. The left and top members will be 0. The right and bottom members will contain the width and height of the window.

void MoveWindow( int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE );
void MoveWindow( LPCRECT lpRect, BOOL bRepaint = TRUE );
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.





尹成 2010-05-04
  • 打赏
  • 举报
回复
参考设置:
RECT orec;
GetWindowRect(hwnd,&orec);
MoveWindow(hwnd,0,0,orec.right - orec.left,orec.bottom - orec.top,TRUE);

15,979

社区成员

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

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