Open help file (chm) in specific page

moongodess

Active member
Joined
Dec 23, 2004
Messages
40
Hi!

Im trying to open a chm file in a specific page, but i cant find out how to do this..

In my old vb6 project I had a module with the code:


Option Explicit

Private Declare Function hHelp Lib "HHCtrl.ocx" Alias "HtmlHelpA" ( _
ByVal hWndCaller As Long, ByVal pszFile As String, ByVal uCommand As Long, dwData As Any) As Long

Private Const HH_DISPLAY_TOPIC = &H0
Private Const HH_HELP_CONTEXT = &HF

Private Const HLP_FILE = "HELP Host FO - SEF.chm"

Public Const HLP_INDEX = "Index.htm"
Public Const HLP_BD = "ConfigurarLigacaoBd.htm"
Public Const HLP_INI = "IniInterface.htm"
Public Const HLP_INICONFIG = "IniInterfaceConfiguracoes.htm"
Public Const HLP_INIEXEC = "IniInterfaceExecutar.htm"


Public Sub gsOpenHelp(strWhatHelp As String)
On Error GoTo Err_Init
Dim strPath As String
Dim strFile As String

strPath = App.Path
strFile = HLP_FILE

ChDir strPath

hHelp 0, strFile, HH_DISPLAY_TOPIC, ByVal strWhatHelp

Exit Sub
Err_Init:
gsError Err.Number, Err.Description
Exit Sub
End Sub

I used the upgrade tool from vb.net to have an idea on how to do this and the result was exactly the same peace of code.

I verified that it open the file, but not in the page i tell it to open..
Anyone knows how can I do this?
 
take a look at the Help Class in System.Windows.Forms , its as easy as this ... ( assuming you have the full url )

Help.ShowHelpIndex(Me, "mk:@MSITStore:C:\Documents%20and%20Settings\den\My%20Documents\IL%20ASM%20BOOK\IS_001\ASSEMBLE.CHM::/assemblehtml/32ch03b.htm")
;)
 
The problem is, when I use something like
Help.ShowHelpIndex(Me, "mk:@MSITStore:C:\Documents%20and%20Settings\den\My%20Documents\IL%20AS M%20BOOK\IS_001\ASSEMBLE.CHM::/assemblehtml/32ch03b.htm")
it will open the file in internet explorer browser, not like an chm file :(
The page is the correct, etc, but I have to open the file like chm, not like html.
 
sorry i forgot to mention , to show inside the help file its self ( rather than explorer ) , you need to use the HelpProvider to specify the location of your .chm file , eg:
Code:
        Dim hlp As New HelpProvider
        hlp.HelpNamespace = "C:\Documents and Settings\den\My Documents\IL ASM BOOK\IS_001\ASSEMBLE.CHM"
        hlp.SetHelpNavigator(Me, HelpNavigator.Topic)
        Help.ShowHelp(Me, hlp.HelpNamespace, HelpNavigator.Topic, "mk:@MSITStore:C:\Documents%20and%20Settings\den\My%20Documents\IL%20ASM%20BOOK\IS_001\ASSEMBLE.CHM::/assemblehtml/32ch03b.htm")
 
I tried your suggestion, but it didnt work.
It open the help file, but not in the page I want it to..

But, finally, a light came to my mind :)
The solution was in front of my nose :rolleyes: And I couldnt see it..

Here is the code:

strHtml: name of the html file to be opened
HelpFile: Constant with the name of the chm file (ex: WhoTo.chm)
strFile: Will contain the complete location and name of the help file
New System.Windows.Forms.Control: because its within a module, if you post the code in a form use the name of the form

Public Sub HelpOpen(ByVal strHtml As String)
On Error GoTo ShowError

Dim strFile As String = Application.StartupPath & "\" & HelpFile

If (strHtml = "") Then if you havent specified a page it will open index
Help.ShowHelpIndex(New System.Windows.Forms.Control,strFile)
Else
Help.ShowHelp(New System.Windows.Forms.Control, strFile, strHtml)
End If

Exit Sub
ShowError:
InfoError(Err.Number, Err.Description)
Exit Sub
End Sub
Thanks everyone who spend more than a second reading this post ;)
 
Back
Top