Share via


WM_SIZE Code Example

Send Feedback

Use the WM_SIZE notification for detecting screen rotations for, and performing processing on all full-screen application windows. The following code is an example of a window's WndProc function that includes a case statement for handling the WM_SIZE notification.

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message) 
     {
         // The code for handling other Windows messages has been omitted for clarity.
         // ...
        case WM_SIZE:
            {
                INT nWidth = LOWORD(lParam);
                HWND hEditBox = GetDlgItem(hWnd, IDC_EDIT);
                HWND hEnterButton = GetDlgItem(hWnd, IDC_BUTTON);

                MoveWindow(hEditBox, 8, 4, nWidth - 70, 20, TRUE);
                MoveWindow(hEnterButton, nWidth - 57, 4, 50, 20, TRUE);
            }
            break;
    }
}

See Also

Screen Orientation Modes | WM_SETTINGCHANGE Code Example

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.