Scrollbars part 8 – Integral interactive resizing

Enforcing integrality solves the fractional-line problem, but notice that when you grab the top or bottom edge and resize the window, the resize feedback doesn't match the actual window you get back if you drag the window to a non-integral size. (You may need to turn off full window drag to see this effect more clearly.)

The WM_SIZING message lets us adjust the feedback during window resizing. We will adjust the rectangle to match the rectangle that will result when you let go of the mouse.

void OnSizing(HWND hwnd, WPARAM wmsz, LPRECT prc)
    AdjustSizeRectangle(hwnd, wmsz, prc);

    /* Add to WndProc */
    case WM_SIZING: OnSizing(hwnd, wParam, (LPRECT)lParam); return TRUE;

Observe that now, when you resize the window, the resizing feedback accurately represents the resulting size of the window. As you drag the mouse vertically or horizontally, the rectangle skips in integral units.

Exercise: If we are enforcing integrality during resizing, why do we also need to enforce integrality in WM_WINDOWPOSCHANGING, too?

Skip to main content