If you have defined a menu resource in a resource-definition file, you can use the menu resource to create a menu bar in a standard window. You include the menu bar by using the FCF_MENU attribute flag and specifying the menu-resource identifier in a call to WinCreateStdWindow, as shown in the following code fragment:

    #define ID_MENU_RESOURCE 100

    HWND hwndFrame;
    CHAR szClassName[]="MyClass";
    CHAR szTitle[]="My Title";

    ULONG flControlStyle = FCF_MENU     | FCF_SIZEBORDER |
                           FCF_TITLEBAR | FCF_ACCELTABLE;

    hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
        WS_VISIBLE,
        &flControlStyle,
        szClassName,
        szTitle,
        0, (HMODULE) NULL,
        ID_MENU_RESOURCE,
        NULL);

After you make this call, the operating system automatically includes the menu in the window, drawing the menu bar across the top of the window. When the user chooses an item from the menu, the menu posts the message to the frame window. The frame window passes any WM_COMMAND messages to the client window. (The frame window does not pass WM_SYSCOMMAND messages to the client window.) WM_HELP messages are posted to the focus window. The WinDefWindowProc function passes WM_HELP messages to the parent window. If a WM_HELP message is passed to a frame window, the frame window calls the HK_HELP hook. Your client window procedure must process these messages to respond to the user's actions.


[Back] [Next]