Drawing the Minimized View

When an application creates a standard frame window, it has the option of specifying an icon that the system uses to represent the application in its minimized state. Typically, if an icon is supplied, the system draws it in the minimized window and labels it with the name of the window. If the application does not specify the FS_ICON style for the window, the window receives a WM_PAINT message when it is minimized. The code in the window procedure that handles the WM_PAINT message can determine whether the frame window currently is minimized and draw accordingly. Notice that because the WS_MINIMIZED style is relevant only for the frame window, and not for the client window, the window procedure checks the frame window rather than the client window.

The following code fragment shows how to draw a window in both the minimized and normal states:

    MRESULT EXPENTRY ClientWndProc(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
    {
        HPS hps;
        RECTL rcl;
        ULONG flStyle;

        switch (msg) {
            case WM_PAINT:
                hps = WinBeginPaint(hwnd, (HPS) NULL, &rcl);

                         /* Check whether the frame window
                          (client's parent window)
                           is minimized.               */

                flStyle = WinQueryWindowULong(WinQueryWindow(hwnd,
                    QW_PARENT), QWL_STYLE);

                if (flStyle & WS_MINIMIZED) {
                    .
                    .    /* Paint the minimized state. */
                    .
                }
                else {
                    .
                    .    /* Paint the normal state.    */
                    .
                }
                WinEndPaint(hps);
                return 0;
        }
    }


[Back: The WM_PAINT Message]
[Next: Drawing Without the WM_PAINT Message]