You receive a "No help ID matches control ID # 0" error message when you right-click on a dialog box for context-sensitive help (822331)



The information in this article applies to:

  • Microsoft Visual C++ Standard Edition, version 6.0

SYMPTOMS

When you use "What's This Help" 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 "Symptoms" 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(),
      "hlp\\Myhelp.chm::/dlgctrl.txt",
      HH_TP_HELP_CONTEXTMENU,
      (DWORD)(LPVOID)myarray);
	}
}

STATUS

This behavior is by design.

MORE INFORMATION

Steps to reproduce the behavior

  1. Start Microsoft Visual Studio 6.0.
  2. On the File menu, Click New.
  3. 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.
  4. In the MFC AppWizard - Step 1 dialog box, click to select the Dialog based check box, and then click Next.
  5. In the MFC AppWizard - Step 2 of 4 dialog box, click to select the Context-sensitive Help check box, and then click Finish.
  6. Click OK to close the New Project Information dialog box.
  7. On the Class View tab, right-click the CmyhelpDlg class, and then click Add Windows Message Handler.
  8. 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.
  9. Follow these steps:
    • Set the value of the HelpID property of each control where "What's This Help" is required to true. To set the HelpID property, follow these steps:
      1. Right-click the control, and then click Properties.
      2. On the General tab, click to select the HelpID check box.
    • 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
    • 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
      	};
      
      	::HtmlHelp(
            pWnd->GetSafeHwnd(),
            "hlp\\Myhelp.chm::/dlgctrl.txt",
            HH_TP_HELP_CONTEXTMENU,
            (DWORD)(LPVOID)myarray);
      }
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 ProjectName.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

REFERENCES

For more information about creating context-sensitive help text files, visit the following Microsoft Developer Network (MSDN) Web site:

Modification Type:MajorLast Reviewed:2/9/2004
Keywords:kberrmsg kbHTMLObj kbDlg kbAPI kbAppWizard kbCSHelp kbprb KB822331 kbAudDeveloper