共用方式為


Receiving HTML Help Notification Messages in an MFC Application

To receive notification messages from HTML Help within an MFC program, you must:

  1. Define a symbol in your Visual C++ project. This example uses a symbol called ID_HHNOTIFICATION.

    • To define a symbol, right-click the high-level folder in ResourceView and select Resource Symbols.

    • In the Resource Symbols dialog box, click New and define the new symbol.

  2. In your Visual C++ project, initialize the HH_WINTYPE structure and call the HTMLHelp function to set this structure using the HH_SET_WIN_TYPE command. Use ID_HHNOTIFICATION for the idNotify field in the structure.

  3. Override the OnNotify function in the derivative of the CWnd class that you want to receive the message (the CWnd class associated with HWND specified in the hwndCaller field of the WW_WINTYPE structure). The following example shows how an OnNotify function is used to call an OnNavComplete(HHN_NOTIFY*, LRESULT) handler whenever HTML Help navigates to a topic:

    BOOL CMyDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
    {
       NMHDR* pNMHDR = (NMHDR*)lParam;
       switch (pNMHDR->idFrom)
       {
          case ID_HHNOTIFICATION:  // whatever id you placed in idNotify of HH_WINTYPE
             if (pNMHDR->code == HHN_NAVCOMPLETE)
             {
                OnNavComplete((HHN_NOTIFY*) lParam, pResult);
                return TRUE;
             }
             break;
       }
    
       return CDialog::OnNotify(wParam, lParam, pResult);
    }
    

See Also

Concepts

HTML Help: Context-Sensitive Help for Your Programs