Jeffrey&Lynny

一个温馨小家庭的.Net生活

导航

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.

posted on 2005-01-04 17:21  比尔盖房  阅读(869)  评论(0编辑  收藏  举报