overview.hlp (Table of Contents; Topic list)
Using Title-Bar Controls (1.2)
About Section  Message Group                      Up Next Previous
────────────────────────────────────────────────────────────────────────────
 
                          Using Title-Bar Controls
 
Typically, you need not be too concerned with the title-bar control. The
default behavior of the title-bar control follows the standard
user-interface guidelines. Most applications allow the title-bar control to
operate according to these guidelines.
 
To include a title-bar control in a standard frame window, the application
must compare (by using the OR operator) constants representing each control
type and pass the resulting value to the WinCreateStdWindow function. The
following code fragment shows the creation of a standard frame window with a
title bar, a minimum-maximum control, a size border, a System menu, and an
application menu. (The System menu and application menu are considered frame
controls. For more information about frame controls, see the topic
Frame windows.)
 
ULONG lControlStyle = FCF_TITLEBAR | FCF_SIZEBORDER |  FCF_MINMAX |
    FCF_SYSMENU | FCF_MENU;
 
hwndFrame = WinCreateStdWindow (HWND_DESKTOP,
    WS_VISIBLE | FS_ACCELTABLE,
    &lControlStyle,
    szClassName,
    szClassName,
    0L, NULL,
    ID_MENU_RESOURCE,
    &hwndClient);
 
Once the frame controls are in place in the frame window, most applications
can ignore them. The system handles the frame controls. In some cases, the
application may take control of the title bar by sending messages to the
title-bar control window.
 
To get the window handle of a title-bar control in a frame window, the
application calls the WinWindowFromID function with the frame-window handle
and a constant identifying the title-bar control, as shown in the following
code:
 
hwndTitleBar = WinWindowFromID(hwndFrame, FID_TITLEBAR);
 
To change the text of a title bar, the application sets the window text of
the frame window by calling the WinSetWindowText function. The frame window
passes the message to the title bar. This changes the title-bar text.
 
Altering Dragging Action
 
When the user clicks in the title-bar control, the title bar sends a
WM_TRACKFRAME message to its owner (the frame window). The frame window also
sends a WM_QUERYTRACKINFO message to itself to fill in a TRACKINFO structure
that defines the tracking parameters and boundaries. To modify the default
behavior, you must subclass the frame window and intercept the
WM_QUERYTRACKINFO message and modify the TRACKINFO structure. If you return
TRUE for the WM_QUERYTRACKINFO message, the tracking information proceeds
according to the information in the TRACKINFO structure. If you return
FALSE, no tracking occurs.
 
Default Title-Bar Behavior
 
This section describes all the messages specifically handled by the
predefined title-bar control class.
 
Message               Description
────────────────────────────────────────────────────────────────────────────
WM_CREATE             Sets the window text for the control. Return FALSE if
                      creation succeeds.
 
WM_DESTROY            Frees the window text for the control.
 
WM_QUERYWINDOWPARAMS  Returns the requested window parameters.
 
WM_SETWINDOWPARAMS    Sets the specified window parameters.
 
WM_PAINT              Draws the title bar.
 
WM_HITTEST            Always returns HT_NORMAL, so the title bar does not
                      beep when it is disabled (it is disabled when the
                      frame window is maximized).
 
WM_BUTTON1DOWN        Sends the WM_TRACKFRAME message to the owner
                      (typically a frame window) to start tracking.
 
WM_BUTTON1DBLCLK      Restores the window if the owner window is minimized
                      or maximized. If the window is neither, maximizes the
                      window.
 
WM_WINDOWPOSCHANGED   Returns FALSE. Process this message to prevent the
                      WinDefWindowProc function from sending the size and
                      show messages.
 
WM_QUERYDLGCODE       Returns the predefined constant DLGC_STATIC. A user
                      cannot use the TAB key to move to this window in a
                      dialog box.
 
TBM_QUERYHILITE       Returns the highlight state of the title bar.
 
TBM_SETHILITE         Sets the highlight state of the title bar, repainting
                      it if the state is changing.
 
 
                                      ♦