Including a Title Bar in a Frame Window

An application can include a title bar in a standard frame window by specifying the FCF_TITLEBAR flag in the WinCreateStdWindow function.

The following code fragment shows how to create a standard frame window with a title bar, minimize and maximize (window-sizing) buttons, size border, system menu, and an application menu.

    #define ID_MENU_RESOURCE 101

    HWND hwndFrame,hwndClient;
    UCHAR szClassName[255];

    ULONG flControlStyle = FCF_TITLEBAR | FCF_MINMAX | FCF_SIZEBORDER |
                           FCF_SYSMENU  | FCF_MENU;

    hwndFrame = WinCreateStdWindow(HWND_DESKTOP, WS_VISIBLE | FS_ACCELTABLE,
                                   &flControlStyle, szClassName, "",
                                   0, (HMODULE) NULL, ID_MENU_RESOURCE,
                                   &hwndClient);

To get the window handle of a title-bar control, an application calls WinWindowFromID, specifying the frame-window handle and a constant identifying the title-bar control, as shown in the following code fragment:

    hwndTitleBar = WinWindowFromID(hwndFrame, FID_TITLEBAR);

To set the text of a title bar, an application can use the WinSetWindowText function. The frame window passes the new text to the title-bar control in a WM_SETWINDOWPARAMS message.


[Back: Using Title-Bar Controls]
[Next: Altering Dragging Action]