Search code examples
c++winapiresize

capture the last WM_SIZE


When I resize my window I want to tell another part of my program that my window has changed size. I read on MSDN that:

WM SIZE Message
The WM SIZE message is sent to a window after its size has changed.

However, I receive the WM_SIZE even when dragging. I noticed that there is also a WM_SIZING message that is sent when my window is resizing. At the moment I do not see the difference between WM_SIZE and WM_SIZING.

Is there some way I can capture the very last WM_SIZE message, as to not "spam" my program with resize messages?


Solution

  • When you start dragging a window, the system enters a modal move/resize loop; it does not return to your own message loop until the drag action has finished. You are still getting WM_SIZE because it is sent directly to the window procedure, but it does not flow through your own message loop.

    At the beginning of such a modal drag action, the system sends WM_ENTERSIZEMOVE to your window procedure. When you release the mouse button, your application will get WM_EXITSIZEMOVE. That is probably the message you want to trigger on.