By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,106 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,106 IT Pros & Developers. It's quick & easy.

How to open a help file (.chm)

P: 23
Hi, I'm new on this website as you may already know. I've created a nifty calculation program (not a calculator, a simultaneous equation solver). I've also created a help file named 'help.chm'. I'm trying to make a menu item open it without having a dialog box come up, but I don't know how to do that, so can anyone help me please.
I'm new to VB so i'm not so good at it right now.
Jun 27 '06 #1
Share this Question
Share on Google+
4 Replies

P: 92
Hi str1ker
Go to the project properties there u see the option of Help File Name here u write ur .chm file Name. its enough.

Run ur software and when u press F1 key then ur Help file is excuted.
Aug 21 '06 #2

P: 1
I like the sound of this program, hope it works!
to launch i would use:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyCode
Case Keys.F1
Process.Start(System.IO.Path.Combine(Application.S tartupPath, "help.chm"))
End Select
End If
End Sub

this assigns it to run when the user presses F1.
Jan 6 '08 #3

P: 2
For Visual Basic 2005 users, this might help you a little better..

The first sub routine opens the help file if a toolbar menu item is clicked, and the second opens the help file when the HelpRequested button (F1) is pressed on that form.

Private Sub HelpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HelpToolStripMenuItem.Click

Process.Start(My.Application.Info.DirectoryPath & "\MyHelp.chm")

End Sub

Private Sub MyFormName_HelpRequested(ByVal sender As Object, ByVal hlpevent As System.Windows.Forms.HelpEventArgs) Handles Me.HelpRequested

Process.Start(My.Application.Info.DirectoryPath & "\MyHelp.chm")

End Sub
Jun 25 '08 #4

P: 2
It should be noted that there is a better way to implement a CHM Help file into your VB 2005 application.

The easy way;
1.) Simply add your existing CHM file to your Project and set it to Copy Always or Copy If Newer.

2.) On your form, drag and drop in a HelpProvider from the Components Toolbox.

3.) In your Form Properties, adjust the setting "HelpButton" to TRUE and adjust the setting "HelpNavigator on HelpProvider1" to TableOfContents.

4.) Adjust the "HelpNameSpace" of the HelpProivder1 component to the name of your CHM file. ie. MyHelpFile.chm


You can also optionally set the "HelpString" or "HelpKeyword" properties of your form, which enable you to send your user to a specific spot in your CHM, assuming you've built it correctly.

When a user presses F1 the CHM opens. This method also prevents the user from opening multiple copies of the same help document.

To create your CHM, I recommend the antiquainted but well suited HTML Help Workshop by Microsoft. It's old, but works like a champ. Besides, the real gloss of your help file is the HTML/CSS, not the program you used to compile a CHM anyway.

The method mentioned in the previous post, while it works, would also require you capture the EventHandler of the process and track when the process exited.

However, if you insist on doing it the hard way, here's some bonus junk;

Public WithEvents p As Process '-- Help File Process Handler
Public IsMyHelpFileOpen As Boolean = False '-- Store Current State of Help File

Public Function OpenHelp(ByVal CurrentState As Boolean) As Boolean

'-- Open the help CHM file. If already open, close it, and reopen it.
'-- Incredible Mouse


If CurrentState = True Then
p = New Process()
End If

' Handle the Exited event that the Process class fires.
AddHandler p.Exited, AddressOf p_Exited
p.EnableRaisingEvents = True
p.SynchronizingObject = Me
p.StartInfo.FileName = My.Application.Info.DirectoryPath & "\MyHelpFileName.chm"
IsMyHelpFileOpen = True
OpenHelp = True

Catch ex As Exception

OpenHelp = False

'--Write to the event log.
Dim sEvent As String
sEvent = My.Resources.HelpFileFailure
If Not EventLog.SourceExists(sSource, sMachine) Then
End If
Dim ELog As New EventLog(sLog, sMachine, sSource)
ELog.WriteEntry(sEvent, EventLogEntryType.Warning, 2001, CType(1, Short))

MsgBox("Error: " & Err.Description, MsgBoxStyle.Exclamation, "Error Encountered")
Exit Function

End Try

End Function

Private Sub p_Exited(ByVal sender As Object, ByVal e As System.EventArgs)

'-- When the CHM file is closed, this returns a false to the public variable IsMyHelpFileOpen.

IsMyHelpFileOpen = False

End Sub
Jun 25 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.