SetWindowPos(...) 的一些注意事项。

        前些天在调整控件位置,总是出现非预想的错误。我完全没有注意到msdn关于参数的注释:

hWnd
[in] Handle to the window.
hWndInsertAfter
[in] Handle to the window to precede the positioned window in the Z order. This parameter must be a window handle or one of the following values.
X
[in] Specifies the new position of the left side of the window, in client coordinates.
Y
[in] Specifies the new position of the top of the window, in client coordinates.
cx
[in] Specifies the new width of the window, in pixels.
cy
[in] Specifies the new height of the window, in pixels.

其中X,Y 都是对应于 hWndInsertAfter 的 客户区 坐标。也就是说,关于定位的计算,都应该通过GetClientRect。特别是有着边框(Frame)的控件,直接导致GetWindowRect 与 GetClientRect 所得到的长宽不同。

看MSDN要仔细啊,那么细小的问题。
      

posted on 2007-03-18 00:15  norsd  阅读(178)  评论(0编辑  收藏  举报

导航