Solved

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

Posted on 2004-08-20
3
530 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 86

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

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA error replacing data 6 41
Excel VBA, find a string in a column, update a cell 7 104
VBA Shell can't Find Word document 11 131
Can we place a tooltip on the actual vb6 form 5 53
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

696 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