Microsoft KB Archive/822331

= You receive a &quot;No help ID matches control ID # 0&quot; error message when you right-click on a dialog box for context-sensitive help =

Article ID: 822331

Article Last Modified on 5/23/2007

-

APPLIES TO


 * Microsoft Visual C++ 6.0 Standard Edition

-



SYMPTOMS
When you use &quot;What's This Help&quot; by calling the HTMLHelp API and by choosing the context-sensitive help option in your project, you may receive the following error message in a dialog box if you right-click on a dialog box and if the pointer is not over the control that contains context-sensitive help:

HH_TP_HELP_WM_HELP/HH_TP_HELP_CONTEXTMENU: No help ID matches control ID # 0

If you right-click the dialog box when the pointer is over one of the controls that contains context-sensitive help, the error message does not appear.



CAUSE
This problem occurs because the Help ID for the control ID #0 is not present in the HTML Help file. Because no control ID exists for a dialog box, right-clicking on a dialog box when the pointer is not over the control causes the error message that is mentioned in the &quot;Symptoms&quot; section of this article.



RESOLUTION
To resolve this problem, use the GetDlgCtrlID method in the OnContextMenu handler to get the control ID, and then call the HTMLHelp API only if the control ID is greater than 0. For more information, see the following code: void CMyhelpDlg::OnContextMenu(CWnd* pWnd, CPoint point) {   static DWORD myarray[] = { IDC_APPLY, 1, IDC_RADIO1, 2, 0,0   };

int control_id = pWnd->GetDlgCtrlID; if (control_id > 0) { ::HtmlHelp(     pWnd->GetSafeHwnd,      &quot;hlp\\Myhelp.chm::/dlgctrl.txt&quot;,      HH_TP_HELP_CONTEXTMENU,      (DWORD)(LPVOID)myarray); } }



STATUS
This behavior is by design.



Steps to reproduce the behavior
 Start Microsoft Visual Studio 6.0. On the File menu, Click New. In the New dialog box, click the Projects tab, click MFC AppWizard(exe) in the list of project types, name the project as Myhelp, and then click OK. In the MFC AppWizard - Step 1 dialog box, click to select the Dialog based check box, and then click Next. In the MFC AppWizard – Step 2 of 4 dialog box, click to select the Context-sensitive Help check box, and then click Finish. Click OK to close the New Project Information dialog box.</li> On the Class View tab, right-click the CmyhelpDlg class, and then click Add Windows Message Handler.</li> In the New Windows Message and Event Handlers dialog box, click WM_CONTEXTMENU in the New Windows messages/events list, click Add Handler, and then click OK.</li> Follow these steps: <ul> Set the value of the HelpID property of each control where &quot;What's This Help&quot; is required to true. To set the HelpID property, follow these steps: <ol> Right-click the control, and then click Properties.</li> On the General tab, click to select the HelpID check box.</li></ol> </li>  Create a context-sensitive help text file (for example, Dlgctrl.txt) with topics that are specified about the controls with the following code: .topic 1 help text for control APPLY .topic 2 help text for control RADIO1 </li>  Implement the handler for the WM_CONTEXTMENU message in the dialog class (in this case, the handler implementation is MyhelpDlg.cpp). To do this, use the following code: void CMyhelpDlg::OnContextMenu(CWnd* pWnd, CPoint point) {   // Add your message handler code here. static DWORD myarray[] = { IDC_APPLY, 1, IDC_RADIO1, 2, 0,0   };

} </li></ul> </li></ol>

Note If you build a Visual C++ 6.0 project with the Context-sensitive Help check box selected in the MFC AppWizard step-1 dialog box, a default WinHelp project is created. When Visual C++ 6.0 was developed, HTMLHelp did not exist. Therefore, you must create your own .chm file by using the HTML Help Workshop.

In WinHelp, context-sensitive help IDs are automatically generated when the .hlp file is generated. The help IDs are stored in the file that is named .hm (in this example, the file name is Myhelp.hm).

Therefore, to use HTMLHelp in a Visual C++ 6.0 project, you must click to select the context-sensitive help check box in the build steps, and then manually convert the project to use HTMLHelp. To do this, follow these steps:
 * 1) Start HTML Help Workshop
 * 2) On the File menu, Click New, and then click Project.
 * 3) In the New Project dialog box, click to select the Convert WinHelp Project check box, and then click Next.
 * 4) Click the Browse button to specify the WinHelp project file, and then click the Browse button to specify the HTML Help project (.hhp) file to be created. Click Next, and then click Finish.
 * 5) Add the context-sensitive help file with a full path name under the [FILES] section in the .hhp file.
 * 6) Create an Index file. To do this, click New on the File menu, and then click Index.
 * 7) Compile to create the .chm file. To do this, click Compile on the File menu, specify the .hpp file by clicking the Browse button.

To use the HTMLHelp API, include the following header file and library file:
 * Header file: include htmlhelp.h
 * Library file: Use htmlhelp.lib

<div class="references_section">