Trouble with HTMLHelp in Outlook Visual Basic COM Addin

B

Bruce

I'm sure I'm just missing something simple.

I've developed a COM addin for Outlook in Visual Basic and created an
HTMLHelp file for same.

I setup the path to the application help file in the addin. I've created the
appropriate help context IDs.

When pressing F1 to launch help, it does launch...but it also launches
Outlook Help at the same time and in a different window. Is this because I
don't have a form wHnd ? I'm not calling the Help from the Help API...just
relying on Visual Basic Project help file setup and context IDs and F1.

Any help would be appreciated.

Thanks.

Bruce
 
F

Fredrik Wahlgren

Bruce said:
I'm sure I'm just missing something simple.

I've developed a COM addin for Outlook in Visual Basic and created an
HTMLHelp file for same.

I setup the path to the application help file in the addin. I've created the
appropriate help context IDs.

When pressing F1 to launch help, it does launch...but it also launches
Outlook Help at the same time and in a different window. Is this because I
don't have a form wHnd ? I'm not calling the Help from the Help API...just
relying on Visual Basic Project help file setup and context IDs and F1.

Any help would be appreciated.

Thanks.

Bruce

Do you want *only* your help file to launch when pressing F1? That doesn't
seem like a good idea. Your users expect F1 to launch Outlook Help. I think
it would be much better if you had a help menu item instead. I think you
need to use the Help API in your code.

/ Fredrik
 
K

Ken Slovak - [MVP - Outlook]

You haven't shown your code, but to only display your help when F1 or a help
button is clicked in one of your forms or your property page you need to do
a few things.

First you need to include all your help declarations, second you need to set
your addin and property page help settings, then you need to handle F1 and
other help calls a specific way to avoid:
1. also opening the Outlook help.
2. crashing Outlook or your addin if the form or property page that
displayed the help is closed prior to closing the Help window.

Here's what I do:

In my init code for the addin (VB 6):
App.HelpFile = g_strHelpDir 'path to help file, same code line used in
property page init code

Help declarations:

'HTML Help API
Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" _
(ByVal hwndCaller As Long, ByVal pszFile As String, _
ByVal uCommand As Long, ByVal dwData As Long) As Long

Public Const HH_DISPLAY_TOPIC = &H0
Public Const HH_SET_WIN_TYPE = &H4
Public Const HH_GET_WIN_TYPE = &H5
Public Const HH_GET_WIN_HANDLE = &H6
Public Const HH_DISPLAY_TEXT_POPUP = &HE ' Display string resource ID or
text in a pop-up window.
Public Const HH_HELP_CONTEXT = &HF ' Display mapped numeric value in
dwData.
Public Const HH_TP_HELP_CONTEXTMENU = &H10 ' Text pop-up help, similar to
WinHelp's HELP_CONTEXTMENU.
Public Const HH_TP_HELP_WM_HELP = &H11 ' text pop-up help, similar to
WinHelp's HELP_WM_HELP


Call to help from a form or Help button or PropertyPage_GetPageInfo event:
SendKeys "{F1}", False
This is used for example in PropertyPage_GetPageInfo and in cmdHelp_Click().

From UserControl_KeyDown(KeyCode As Integer, Shift As Integer) in property
page:
On Error Resume Next

If KeyCode = vbKeyF1 Then
Call HtmlHelp(0, g_strHelpDir, HH_HELP_CONTEXT, 1500) 'property page
help context
End If

From Form_KeyDown(KeyCode As Integer, Shift As Integer) in a form:
Dim iRetCode As Long

On Error Resume Next

If KeyCode = vbKeyF1 Then
iRetCode = HtmlHelp(0, g_strWinDir, HH_HELP_CONTEXT, 1600) 'form help
context
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top