Solved

Button Click -> Execute Help .chm file (VB6)

Posted on 2004-08-20
3
515 Views
Last Modified: 2008-02-01
is there a simple way to open a .chm help file when a button is clicked.  I already have it press F1 for help.

This is in VB6

Thx

JB
0
Comment
Question by:jamesbenson
3 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 125 total points
ID: 11855761
If you have already set the "Help File Name" property in the Project Properties then it is simple as sending F1 to the application:

Private Sub Command1_Click()
    If App.HelpFile <> "" Then
        SendKeys ("{F1}")
    End If
End Sub

Regards,

Idle_Mind
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11858759
HTML Help

Const HH_DISPLAY_TOPIC = &H0
Const HH_SET_WIN_TYPE = &H4
Const HH_GET_WIN_TYPE = &H5
Const HH_GET_WIN_HANDLE = &H6
Const HH_DISPLAY_TEXT_POPUP = &HE   ' Display string resource ID or text in a pop-up window.
Const HH_HELP_CONTEXT = &HF         ' Display mapped numeric value in  dwData.
Const HH_TP_HELP_CONTEXTMENU = &H10 ' Text pop-up help, similar to WinHelp's HELP_CONTEXTMENU.
Const HH_TP_HELP_WM_HELP = &H11     ' text pop-up help, similar to WinHelp's HELP_WM_HELP.
Const HH_CLOSE_ALL = &H12
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 Form_Load()
    'KPD-Team 2000
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    Dim hwndHelp As Long
    'The return value is the window handle of the created help window.
    hwndHelp = HtmlHelp(hWnd, "myfile.chm", HH_DISPLAY_TOPIC, 0)
End Sub
Private Sub Form_Unload(Cancel As Integer)
    HtmlHelp Me.hWnd, "", HH_CLOSE_ALL, 0
End Sub

WinHelp

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&
Private Declare Function WinHelp Lib "user32.dll" Alias "WinHelpA" (ByVal hWndMain As Long, ByVal lpHelpFile As String, ByVal uCommand As Long, dwData As Any) As Long
Private Sub Form_Load()
    'KPD-Team 2000
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    WinHelp Me.hwnd, "C:\Windows\help\common.hlp", HELP_CONTENTS, ByVal 0
End Sub
0
 
LVL 2

Expert Comment

by:gerrymcd
ID: 11898002
sub command1_click()
  dim myhelpfile as str
  myhelpfile="c:\helfile.chm"
  call ExecuteFile(myhelpfile)
end sub


Public Sub ExecuteFile(FilePath As String)
'Execute a file
On Error GoTo error
Dim ret As Double
ret = Shell("rundll32.exe url.dll,FileProtocolHandler " & (FilePath), vbNormalFocus)
Exit Sub
error:  Error_Handle Err.Description
End Sub
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now