经常使用
PostMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(pt.x, pt.y));
来做按住客户区,也可以拖动窗口。
所以在MSDN里查了一下WM_NCLBUTTONDOWN的意思。
但是还是有疑惑。
WM_NCLBUTTONDOWN的解释The WM_NCLBUTTONDOWN message is posted when the user presses the left mouse button while the cursor is within the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted.
这里是问题:“the nonclient area of a window”是什么意思?nonclient指的是什么?后面一句话:
“If a window has captured the mouse,this message is not posted”
如果一个窗口捕获此鼠标,则消息就不能被post。不被post,那消息怎么会传到caption上的???怎么拖动窗口的???请解释
PostMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(pt.x, pt.y));
来做按住客户区,也可以拖动窗口。
所以在MSDN里查了一下WM_NCLBUTTONDOWN的意思。
但是还是有疑惑。
WM_NCLBUTTONDOWN的解释The WM_NCLBUTTONDOWN message is posted when the user presses the left mouse button while the cursor is within the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted.
这里是问题:“the nonclient area of a window”是什么意思?nonclient指的是什么?后面一句话:
“If a window has captured the mouse,this message is not posted”
如果一个窗口捕获此鼠标,则消息就不能被post。不被post,那消息怎么会传到caption上的???怎么拖动窗口的???请解释
是指如果一个程序捕获了鼠标,即调用了SetCapture,那么这个WM_NCLBUTTONDOWN消息就不会被触发,也就是程序调用了SetCapture,是无法接到这个消息的,因为既然捕获了鼠标,当然是有一些特殊的任务要做,比如检测鼠标位置(不局限于本程序窗口)等,能移动窗口就乱了套了。必须ReleaseCapture后才能再接收到该消息。
HTCLIENT In a client area.
CWnd::OnNcLButtonDown
afx_msg void OnNcLButtonDown( UINT nHitTest, CPoint point );ParametersnHitTestSpecifies the hit-test code. A hit test is a test that determines the location of the cursor.指定了击中测试代码。击中测试用于确定光标的位置。 pointSpecifies a CPoint object that contains the x and y screen coordinates of the cursor position. These coordinates are always relative to the upper-left corner of the screen.指定了一个CPoint对象,其中包含了光标位置的x轴和y轴屏幕坐标。这些坐标总是相对于屏幕的左上角的。 ResThe framework calls this member function when the user presses the left mouse button while the cursor is within a nonclient area of the CWnd object. If appropriate, the WM_SYSCOMMAND is sent.当用户在CWnd的非客户区内按下鼠标左键时,框架调用这个成员函数。如果合适的话,将发出WM_SYSCOMMAND消息。 Note This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received.If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.注意 框架调用这个成员函数以允许你的应用程序处理一个Windows消息。传递给你的成员函数的参数反映了接收到消息时框架接收到的参数。如果你调用了这个函数的基类实现,则该实现将使用最初传递给消息的参数(而不是你提供给这个函数的参数)
如果一个窗口SetCapture了,那么鼠标即使超出了该窗口的范围,但鼠标的消息还是会发送到该窗口.直到该窗口ReleaseCapture.