Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 168
  • Last Modified:

How to open a help file within a Visual Basic application

Hi all,

I am currently testing a method before I add it to my official program. I would like to be able to click a command button and bring up a relevant topic in a help file.

Currently, I know that(under command1_click procedure):

Command1.HelpContextID = 10

will open the topic with an ID of 10 if the button is selected and you press "F1". However, this is not suitable for my purpose and I want it to open the topic on CLICKING the button.

I need this information ASAP. All comments and answers are welcome!!

Regards

CD
0
CDeath
Asked:
CDeath
  • 6
  • 2
1 Solution
 
JohnMcCannCommented:
Private Declare Function OSWinHelp% Lib "user32" Alias "WinHelpA" (ByVal hWnd&, ByVal HelpFile$, ByVal wCommand%, dwData As Any)

Public Sub SearchForHelpOn(frm As Form)
Dim intRet As Integer
    'if there is no helpfile for this project display a message to the user
    'you can set the HelpFile for your application in the
    'Project Properties dialog
    If Len(App.HelpFile) = 0 Then
        MsgBox "Unable to display Search for help on. There is no Help associated with this project.", vbInformation, frm.Caption
    Else
        On Error Resume Next
        intRet = OSWinHelp(frm.hWnd, App.HelpFile, 261, 0)
        If Err Then
            MsgBox Err.Description
        End If
    End If
End Sub

Public Sub HelpContents(frm As Form)
Dim intRet As Integer
    'if there is no helpfile for this project display a message to the user
    'you can set the HelpFile for your application in the
    'Project Properties dialog
    If Len(App.HelpFile) = 0 Then
        MsgBox "Unable to display Help Contents. There is no Help associated with this project.", vbInformation, frm.Caption
    Else
        On Error Resume Next
        intRet = OSWinHelp(frm.hWnd, App.HelpFile, 3, 0)
        If Err Then
            MsgBox Err.Description
        End If
    End If
End Sub
0
 
JohnMcCannCommented:
Const to use as wCommand

Const HELP_COMMAND = &H102&
Const HELP_CONTENTS = &H3&
Const HELP_CONTEXT = &H1
Const HELP_CONTEXTPOPUP = &H8&
Const HELP_FORCEFILE = &H9&
Const HELP_HELPONHELP = &H4
Const HELP_INDEX = &H3
Const HELP_KEY = &H101
Const HELP_MULTIKEY = &H201&
Const HELP_PARTIALKEY = &H105&
Const HELP_QUIT = &H2
Const HELP_SETCONTENTS = &H5&
Const HELP_SETINDEX = &H5
Const HELP_SETWINPOS = &H203&

OSWinHelp Me.hWnd, Me.HelpFile, HELP_CONTEXT, Command1.HelpContextID
0
 
CDeathAuthor Commented:
This is all well and good... but what about my "command1" command button that has to be clicked to display the help?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
CDeathAuthor Commented:
I dont understand where I have to put all this...
0
 
CDeathAuthor Commented:
I dont understand where I have to put all this...
0
 
CDeathAuthor Commented:
Oops double post...
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Try this:

Private Sub Command1_Click()
   Command1.HelpContextID = 10
   SendKeys "{F1}"
End Sub
0
 
CDeathAuthor Commented:
I tried copying the code in but it doesn't understand the "Me" part. I am a newbie to visual basic so you have to be gentle...
0
 
CDeathAuthor Commented:
Thank you so much!! So simple, you have saved my life =)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now