MorrisLiang
MorrisLiang

Reputation: 702

Frustrating dealing with Window Message(WM_XX)

I'm trying to make myself a GUI library using plain WinAPI. But I found that dealing with Window Message really frustrating.

For example, I can see that when I move my mouse over my window, WM_NCHITTEST will send to me before WM_MOUSEMOVE. But if I press down the left button, move around, then release the left button. Then I only receive WM_MOUSEMOVE afterward. Possibly it was because I call SetFocus(HWND), SetCapture(HWND) when receive WM_LBUTTONDOWN and ReleaseCapture(HWND) when receive WM_LBUTTONUP

These different behaviors seem like a mist to me. I wonder is there any documentation / article explaining the details about these Window Message. At least, tell me what I should pay attention to. (Charles's "Programming Windows" doesn't work for me, because it only introduce the basis about those messages, but not telling me traps like I mention about the WM_NCHITTEST / WM_MOUSEMOVE)

Upvotes: 2

Views: 494

Answers (2)

Logan Capaldo
Logan Capaldo

Reputation: 40336

http://msdn.microsoft.com/en-us/library/ms645618(VS.85).aspx http://blogs.msdn.com/b/oldnewthing/archive/2011/02/18/10131176.aspx

WM_NCHITTEST is for hit-testing. It only gets sent when needed. MSDN has documentation on each message. There is also a section on mouse input http://msdn.microsoft.com/en-us/library/ms645533(v=VS.85).aspx

Upvotes: 2

c-smile
c-smile

Reputation: 27460

By saying SetCapture(HWND) you asking system to redirect all mouse messages to your window until you call ReleaseCapture(HWND). When mouse input is captured (so all messages redirected there) by some window there is no need to send WM_NCHITTEST.

If needed you can send WM_NCHITTEST to windows under the mouse by yourself.

Upvotes: 3

Related Questions