overview.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Using Frame Windows (1.2)
About Section  Function Group  Message Group    Up Next Previous
────────────────────────────────────────────────────────────────────────────
 
                            Using Frame Windows
 
The following sections detail creating and using frame windows.
 
Creating a Main Window
 
You can create a main window by using the WinCreateStdWindow function. The
following code fragment creates a typical main window: a frame window that
has a System menu, title bar, menu, vertical and horizontal scroll bars,
minimize and maximize buttons, and a sizing border.
 
/* Create a main window. */
 
ULONG flFrameControlFlags =
    FCF_SYSMENU | FCF_TITLEBAR   | FCF_SIZEBORDER |
    FCF_MENU    | FCF_MINMAX     | FCF_HORZSCROLL |
    FCF_VERTSCROLL;
 
hwndFrame = WinCreateStdWindow(
    HWND_DESKTOP,          /* frame-window parent      */
    0L,                    /* no window styles         */
    &flFrameControlFlags,  /* frame-control flags      */
    "MyClass",             /* client-window class      */
    "Main Window",         /* window title             */
    0L,                    /* no client-window styles  */
    NULL,                  /* app module has resources */
    1,                     /* resource ID              */
    &hwndClient);          /* client-window handle     */
 
You can also create a "standard" main window for an application by creating
a frame window with the FCF_STANDARD style. You create the frame window
using the WinCreateStdWindow function. The following code fragment creates
the window:
 
/* Set the frame-control flags. */
 
ULONG flFrameControlFlags = FCF_STANDARD;
 
hwndFrame = WinCreateStdWindow (HWND_DESKTOP, ..., &hwndClient);
 
Another way to create a main window and its frame controls is by calling the
WinCreateWindow function to create the frame window and the frame controls
and then calling WinCreateWindow to create the client window. One of the
advantages of this approach is that you can specify an initial size and
position of the frame window when you create it. The following code fragment
illustrates this approach:
 
FRAMECDATA fcdata;
 
fcdata.cb = sizeof(fcdata);
fcdata.flCreateFlags = FCF_STANDARD;
fcdata.hmodResources = NULL;
fcdata.idResources   = idFrame;
 
hwndFrame = WinCreateWindow(
    HWND_DESKTOP,   /* frame-window parent            */
    WC_FRAME,       /* frame-window class             */
    "Main Window",  /* window title                   */
    0L,             /* initially invisible            */
    0, 0, 0, 0,     /* size and position = 0          */
    NULL,           /* no owner                       */
    HWND_TOP,       /* top Z-order position           */
    idFrame,        /* frame-window ID                */
    &fcdata,        /* pointer to class-specific data */
    NULL);          /* no presentation parameters     */
 
hwndClient = WinCreateWindow(
    hwndFrame,      /* client-window parent           */
    "My Class",     /* client-window class            */
    NULL,           /* no title for client window     */
    0L,             /* initially invisible            */
    0, 0, 0, 0,     /* size and position = 0          */
    hwndFrame,      /* owner is frame window          */
    HWND_BOTTOM,    /* bottom Z-order position        */
    FID_CLIENT,     /* standard client-window ID      */
    NULL,           /* no class-specific data         */
    NULL);          /* no presentation parameters     */
 
/* ... continue initialization ... */
 
WinShowWindow(hwndFrame, TRUE);
 
Retrieving Frame Handles
 
You can easily retrieve a frame-control handle by using the WinWindowFromID
function. The following code fragment retrieves the control handle of the
title bar:
 
hwndTitleBar = WinWindowFromID(hwndFrame, FID_TITLEBAR);
 
Given a frame-control handle, you can retrieve its parent frame-window
handle by using the WinQueryWindow function as follows:
 
hwndFrame = WinQueryWindow(hwndTitleBar, QW_PARENT, FALSE);
 
By using identifiers to identify frame controls rather than window classes,
you can create your own controls to replace the predefined controls.
 
 
                                      ♦