---------------------------------------------------------------------- The information in this sample applies to: - Microsoft Foundation Classes for Windows, version 2.0 ---------------------------------------------------------------------- SUMMARY ======= The DLGHLP sample illustrates implementing context sensitive help in an MFC dialog box. MORE INFORMATION ================ The DLGHLP sample implements context sensitive help in a dialog box by overriding CWnd::OnCommandHelp in the dialog class to handle the WM_COMMANDHELP message. WM_COMMANDHELP is a private AFX Windows message that is received by the active window when Help is requested. DLGHLP uses the ID of the currently active control to generate the help context which is passed on to the CWinApp::WinHelp member. DLGHLP includes 2 dialog boxes, each with a number of controls in them. The user is able to set the focus to a particular control and, by pressing F1, bring up help which is specific to that control. Several of the control ID's are used in both dialogs. For example, each dialog contains a radio button control with the ID of IDC_RADIO1. To allow a unique help context value to be generated for each control, the ID of each dialog box is used as a base and is added to the ID of the control. For example, Dialog Box 1 has an ID of IDD_DIALOGBOX1 and Dialog Box 2 has an ID of IDD_DIALOGBOX2, both of which are defined in the header file RESOURCE.H. IDD_DIALOGBOX1 and IDD_DIALOGBOX2 have been made to differ in value by enough that adding the individual control ID's to them does not generate any overlapping help context values. In this case IDD_DIALOGBOX1 has a value of 101 and IDD_DIALOGBOX2 has a value of 131. Since IDC_RADIO1 has a value of 101, adding IDC_RADIO1 to each of the dialog box ID's gives unique help context values of 202 and 232. A base value of 0x20000 is also added the help context value to cause the context value for each control to be in the range of 0x20000 to 0x2FFFF, the help context range for windows and dialogs. For more information on help context ranges and context sensitive help in MFC, refer to MFC Technical Note 28: Context-Sensitive Help Support. DLGHLP illustrates mixing context sensitive help and default help in the same dialog box. Pressing the F1 key when any of the radio buttons in Dialog Box 2 has the focus causes the context sensitive help for the radio button to be used. Pressing F1 when either the OK or Cancel button has the focus causes the default application help index to be invoked. Dialog Box 1 provides context sensitive help for all controls, including the OK and Cancel buttons. DLGHLP is based on an AppWizard generated application. Files included with the sample which are directly related to implementing context sensitive help in a dialog box are: DLGBOX1.CPP - Implements context sensitive help for Dialog Box 1 by overriding CWnd::OnCommandHelp. DLGBOX2.CPP - Implements context sensitive help for Dialog Box 2 by overriding CWnd::OnCommandHelp. DLGRES.H - Defines the help context ID's based on the ID of the dialog box and the specific control. DLGCTRLS.HM - Help map file that defines the help context ID's for the dialog controls.