Microsoft KB Archive/125670

-

{| The information in this article applies to:
 * width="100%"|

Microsoft Win32 Application Programming Interface (API) included with: - Microsoft Windows 95 version 4.0

SUMMARY
In Windows versions 3.x, applications implement context-sensitive help for dialog boxes by installing either a message filter hook, or a task-specific keyboard hook that monitors the WM_KEYDOWN message and responds to F1 key presses.

Windows 95 makes it easier because it provides a new WM_HELP message that gets sent each time the user presses the F1 key, giving the application a chance to bring up help information on the control that has the keyboard focus or on the dialog box itself. This new WM_HELP message is not limited to dialog boxes alone, as it gets sent to any window that has keyboard focus or to the currently active window.

MORE INFORMATION
Windows 95 also provides a new dialog style, DS_CONTEXTHELP that adds a question mark button to the dialog box's caption bar. This button, when clicked, changes the cursor to a question mark with a pointer. When the user clicks any control in the dialog box, Windows 95 sends a WM_HELP message for that control. The dialog procedure should process the WM_HELP message as follows:

// Define an array of dword pairs, // where the first of each pair is the control ID, // and the second is the context ID for a help topic, // which is used in the help file. static const DWORD aMenuHelpIDs[] = {     edt1, IDH_EDT1 , lst1, IDH_LST1 , lst2, IDH_LST2 , 0,   0   };

case WM_HELP: {     LPHELPINFO lphi;

lphi = (LPHELPINFO)lparam; if (lphi->iContextType == HELPINFO_WINDOW)  // must be for a control {        WinHelp (lphi->hItemHandle,                  "GEN32.HLP",                  HELP_WM_HELP,                  (DWORD)(LPVOID)aMenuHelpIDs); }     return TRUE; }

Calling WinHelp with the HELP_WM_HELP parameter as demonstrated above displays the help topic in a pop-up window. In addition to the WM_HELP message, Windows 95 provides a new WM_CONTEXTMENU message that gets sent each time the user right-clicks a window. Typically this message is processed by displaying a context menu using the TrackPopupMenu function. However, this message can be processed to bring up help information by calling the WinHelp function to display the help topic in a pop-up window, as in this example:

case WM_CONTEXTMENU: {     WinHelp ((HWND)wparam,               "GEN32.HLP",                HELP_CONTEXTMENU,               (DWORD)(LPVOID)aSampleMenuHelpIDs); return TRUE; } NOTE: Look at the third parameter (HELP_CONTEXTMENU) passed to WinHelp this time. This causes a pop-up menu to come up that displays "What's This?" text. It then displays the help topic in a pop-up window when the menu item is selected.
 * }

-

Last reviewed: November 3, 1998

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.