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)
By saying
SetCapture(HWND)you asking system to redirect all mouse messages to your window until you callReleaseCapture(HWND). When mouse input is captured (so all messages redirected there) by some window there is no need to sendWM_NCHITTEST.If needed you can send WM_NCHITTEST to windows under the mouse by yourself.