Win32 Dialog Tips

1.  GetWindowRect函数所获得的是Screen坐标,而SetWindowPos函数使用的是相对于被设置窗口的父窗口的区域的坐标(也就是说,对于对话框的自控件,对话框的左上角为坐标0,0)。所以,我们通常使用MapWindowPoints将GetWindowRect函数所获得的坐标进行转换,转换成对话框的相对坐标。如下:
GetWindowRect(GetDlgItem(hDlg, IDC_PLACEHOLDER), &rc);
MapWindowPoints(HWND_DESKTOP, hDlg, (LPPOINT)&rc, sizeof(RECT)/sizeof(POINT));

但是对于对话框本身,SetWindowPos坐标是相对于其父窗口HWND_DESKTOP的,也就是Screen坐标了。所以对于对话框本身,调用SetWindowPos,应该使用Screen坐标。

Note: If the SWP_SHOWWINDOW or SWP_HIDEWINDOW flag is set, the window cannot be moved or sized.
If you have changed certain window data using SetWindowLong, you must call SetWindowPos to have the changes take effect. Use the following combination for uFlags: SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED.

转载于:https://www.cnblogs.com/jeffreytan/archive/2005/01/04/86324.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值