Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening CHM Help file without using commondialog control

Status
Not open for further replies.

JBats

Programmer
Aug 3, 2003
127
PH
Hello guys,

I would like to ask if is there a way I can open my help file (build in CHM format) in my VB application without using commondialog control. My problem rightnow is that when I tried launching the help file using this control, it doesn't work and it says the file is invalid or corrupt.

I already set the helpfile property of my application that is why every time the user presses F1 the help automatically opens. However, i'm looking a command that can be used to perform same task because instead the user presses F1, he might be open a Help Menu and select Help from the sub menus.

Any help would be highly appreciated.

Thanks,


JBats
Good is not better if not than best...
 
'Use this in a public module (declarations)
Code:
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

'hwndCaller = Caller's hwnd
'pszFile = the file and path
'uCommand = What to do
'dwData = HelpContextID

'Help constants
Private Const SHOWTOPIC = &H0
Private Const SHOWTOC = &H1
Private Const SHOWINDEX = &H2
Private Const SHOWHELPCONTEXT = &HF
'Add a public proceedure in the same module and in that proceedure, as an example to show the TOC, call it like this:

Dim ret As Long
ret = HtmlHelp(hwnd, myHTMLFile, SHOWTOC , 0)
 
Thanks for the infor you've shared but my problem when I use this API function is that when I tried to close my application while the help window still open, the application get's freeze. I don't know why and another thing is that the help window is always on top.

Thanks
Jbats

JBats
Good is not better if not than best...
 
As someone has already pointed out

CHM files != HLP files

HLP Files use the common dialog, CHM don't

However, to close the help window before your program exit,
you need to investigate the HH_CLOSE_ALL command which is passed using the HtmlHelp command

so something like

Code:
Private Declare Function CloseHtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" _
         (ByVal hwndCaller As Long, ByVal pszFile As [COLOR=blue]Long[/color], ByVal uCommand As Long, ByVal dwData As Long) As Long

CloseHtmlHelp 0&, 0&, HH_CLOSE_ALL, 0

Of course, you will have to find the value of the HH_CLOSE_ALL constant

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top