Home All Groups Group Topic Archive Search About

How to open a chm file nicely ?

Author
11 Mar 2006 12:56 PM
John S
Hi All,

When I open a chm file from an MDI form using
the command like in sample-1 below,
the fle always appears on top of the form.
Is there any other way so that when I switch to
the form, the chm file automatically goes backward ?

I have tried the sample-2 below. It can open
the file as expected. But it can not work if no child
form opened.

Could you help me ?

Thanks in advance
John S.

'----Sample-1-----
Const HH_DISPLAY_TOPIC = &H0
Private 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

Private Sub mhelp_Click(Index As Integer)
If Index = 1 then
  Dim hwndHelp As Long
  hwndHelp = HtmlHelp(hwnd, App.Path & "\h.chm", HH_DISPLAY_TOPIC, 0)
End If
End Sub


'----Sample-2-----
Private Sub MDIForm_Load()
App.HelpFile = App.Path & "\h.chm"
End Sub

Private Sub mhelp_Click(Index As Integer)
If Index = 1 then
   SendKeys "{F1}"
End If
End Sub



*** Sent via Developersdex http://www.developersdex.com ***

Author
11 Mar 2006 5:04 PM
tlviewer
"John S" <nospam> wrote in message
news:O8piFtQRGHA.336@TK2MSFTNGP12.phx.gbl...
> Hi All,
>
> When I open a chm file from an MDI form using
> the command like in sample-1 below,
> the fle always appears on top of the form.
> Is there any other way so that when I switch to
> the form, the chm file automatically goes backward ?
>

John,
see inline
<snip>
'  don't forget this at the top of your module
Option Explicit

> '----Sample-1-----
> Const HH_DISPLAY_TOPIC = &H0
> Private 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
>
> Private Sub mhelp_Click(Index As Integer)
' without defining hwnd your code won't run

dim hwnd as long
' set it to the form's window handle or you will attach to the desktop
hwnd = Me.hWnd

> If Index = 1 then
>   Dim hwndHelp As Long
>   hwndHelp = HtmlHelp(hwnd, App.Path & "\h.chm", HH_DISPLAY_TOPIC, 0)
> End If
> End Sub
>
>

bye,
tlviewer
Author
11 Mar 2006 9:45 PM
John S
Hi tlviewer

I solved my problem with setting
hwnd = GetDesktopWindow() before hwndhelp = ....

Thank you for your help


*** Sent via Developersdex http://www.developersdex.com ***