Microsoft KB Archive/286404

= How To Add HTML Help to a Visual Basic 6.0 Application Wizard Application =

Article ID: 286404

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft HTML Help 1.2
 * Microsoft HTML Help 1.21
 * Microsoft HTML Help 1.22
 * Microsoft HTML Help 1.3
 * Microsoft HTML Help 1.31
 * Microsoft HTML Help 1.32

-



This article was previously published under Q286404



SUMMARY
This article describes how to add HTML Help to an application that was created using the Visual Basic 6.0 Application Wizard. When you choose to add Help to your menu or to your toolbar, the application wizard adds the necessary code for Winhelp. You need to change the code so that HTML Help is used instead of Winhelp.



MORE INFORMATION
After you build your application by using the application wizard, make the following changes:  Set the Project Properties Help filename. Select Project Properties on the Project menu to open the Project Properties dialog box. In the Help File Name field of the General tab, enter the path and file name for your application's HtmlHelp file. (You can also programmatically set the Help file. For more information see the MSDN topic &quot;Adding Help To Your Application&quot; in the &quot;References&quot; section.)  Replace the Winhelp declaration with an HTML Help declaration. To do this, replace the line that the wizard put at the top of frmMain. Replace this code Private Declare Function OSWinHelp% Lib &quot;user32&quot; Alias &quot;WinHelpA&quot; (ByVal hwnd&, ByVal HelpFile$, ByVal wCommand%, _                                                                  dwData As Any) with this code: Private Declare Function HtmlHelp Lib &quot;hhctrl.ocx&quot; Alias &quot;HtmlHelpA&quot; (ByVal hwndCaller As Long, ByVal pszFile As String, _                                                                     ByVal uCommand As Long, ByVal dwData As Long) As Long   On the next line, add the HTML Help commands you are using. For example: Private Const HH_DISPLAY_TOPIC = &H0 Private Const HH_HELP_CONTEXT = &HF NOTE: For a complete list of all the commands, see the htmlhelp.h file in the &quot;include&quot; folder where the HTML Help Workshop is installed. For information about the command syntax, see the HTML Help online Help, API Reference.

  If you chose to add Help to your menu during the application wizard, the wizard adds two methods, mnuHelpSearchForHelpOn_Click and mnuHelpContents_Click.

You need to replace the calls to Winhelp with calls to the HTML Help API in these methods. (The exact syntax of the commands varies depending on which commands you are using. See the HTML Help online Help for additional information regarding the API commands.) For example, you could replace this code nRet = OSWinHelp(Me.hwnd, App.HelpFile, 261, 0) with this code: dim nRet As Long

nRet = HtmlHelp(Me.hwnd, App.HelpFile, HH_DISPLAY_TOPIC, 0)   If you chose to add Help as a toolbar button during the Application Wizard, the Wizard adds this to the tbToolBar_ButtonClick method: Case &quot;Help&quot; 'ToDo: Add 'Help' button code. MsgBox &quot;Add 'Help' button code.&quot; Remove the MsgBox call and add a call to the HTML Help API, such as: dim nRet As Long nRet = HtmlHelp(Me.hwnd, App.HelpFile, HH_DISPLAY_TOPIC, 0)   If you choose to add &quot;Help What's This&quot; as a toolbar button, then the wizard adds this to your code: Case &quot;Help What's This&quot; 'ToDo: Add 'Help What's This' button code. MsgBox &quot;Add 'Help What's This' button code.&quot; Remove the MsgBox call and add a call to the HTML Help API using the 'HH_HELP_CONTEXT' command, such as: hwndHelp = HtmlHelp(Me.hWnd, App.HelpFile, HH_HELP_CONTEXT, myContextID) NOTE: Adding &quot;What's This&quot; help requires additional steps that are not covered in this article. For more information see the MSDN topic: &quot;Adding Support for What's This Help&quot;. </ol>

<div class="references_section">