Date: 02-16-2022
Return to Index
created by gbSnippets
'Both .hlp and .chm files can be opened with the same code - calling
'ShellExecute to run the default application registered for those extensions
'Primary Code:
Local tempFile As %Max_Path, iResult&
tempFile = Exe.Path$ + "gbsnippets.chm" 'also works on .hlp filenames
iResult& = ShellExecute(hDlg, "Open", tempFile, $Nul, $Nul, %SW_ShowNormal)
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
%ID_MenuHelpFile = 100
Global hDlg As DWord, hMenu As DWord, hMenuHelp As DWord
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
AddMenu
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = %ID_MenuHelpFile Then
Local tempFile As Asciiz * %Max_Path, iResult&
tempFile = Exe.Path$ + "gbsnippets.chm" 'work also on .hlp filenames
iResult& = ShellExecute(hDlg, "Open", tempFile, $Nul, $Nul, %SW_ShowNormal)
End If
End Function
Sub AddMenu()
Menu New Bar To hMenu
Menu New Popup To hMenuHelp
Menu Add Popup, hMenu, "&Help", hMenuHelp, %MF_Enabled
Menu Add String, hMenuHelp, "&Local Help File", %ID_MenuHelpFile, %MF_Enabled
Menu Attach hMenu, hDlg
End Sub
'gbs_00052
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm