Why is Win32 API’s WM_MOVE being called while dragging the window

historywindows

I have two callbacks for WM_MOVE and WM_MOVING. Oddly enough, WM_MOVE is being called while dragging the window. I expected WM_MOVE to be called only when I'm done dragging the window.

MSDN says that WM_MOVE is sent after a window is moved, and WM_MOVING is when the window is moving. The docs don't show any changes for Windows 7/VS2010, which is what I'm using.

WM_MOVE:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632631%28v=vs.85%29.aspx

Has anyone come across this before? On drag, WM_MOVE is called, which it shouldn't be as far as I understand it.

    case WM_MOVE:
        {
            int x = LOWORD(lParam);
            int y = HIWORD(lParam);

            if (win.m_onMoveCallback)
                win.m_onMoveCallback(x, y);

            return 0;
        }
        break;

    case WM_MOVING:
        {
            int x = LOWORD(lParam);
            int y = HIWORD(lParam);

            if (win.m_onMovingCallback)
                win.m_onMovingCallback(x, y);

            return 0;
        }
        break;

Best Answer

Back in the time of Windows 3.1, before Windows 95, you dragged the window, but it did not move. You were only moving an outline of the window, in form of semi-transparent frame. Only when you ended the drag, the window moved (jumping to final position; back then there were no graphics accelerators, so redraw of a window was expensive operation; resize worked similarly).

In Windows 95, one of the big things was, the window actually moved / resized while you were dragging it / its resizing border. Much nicer.

Well, those two WM_XXX messages are tied to dragging the movement frame (now invisible, but still present as a principle) vs. moving the actual window itself. I hope now it is clearer.