Scrollbars part 8 – Integral interactive resizing

Date:August 13, 2003 / year-entry #21
Tags:code
Orig Link:https://blogs.msdn.microsoft.com/oldnewthing/20030813-00/?p=42913
Comments:    0
Summary: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...

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?



*DISCLAIMER: I DO NOT OWN THIS CONTENT. If you are the owner and would like it removed, please contact me. The content herein is an archived reproduction of entries from Raymond Chen's "Old New Thing" Blog (most recent link is here). It may have slight formatting modifications for consistency and to improve readability.

WHY DID I DUPLICATE THIS CONTENT HERE? Let me first say this site has never had anything to sell and has never shown ads of any kind. I have nothing monetarily to gain by duplicating content here. Because I had made my own local copy of this content throughout the years, for ease of using tools like grep, I decided to put it online after I discovered some of the original content previously and publicly available, had disappeared approximately early to mid 2019. At the same time, I present the content in an easily accessible theme-agnostic way.

The information provided by Raymond's blog is, for all practical purposes, more authoritative on Windows Development than Microsoft's own MSDN documentation and should be considered supplemental reading to that documentation. The wealth of missing details provided by this blog that Microsoft could not or did not document about Windows over the years is vital enough, many would agree an online "backup" of these details is a necessary endeavor. Specifics include:

<-- Back to Old New Thing Archive Index