Capture F1

Category: Apps/Dialogs

Date: 07-23-2010

Return to Index


 
'When the user presses F1, windows sends the WM_Help message
'If a menu is active when F1 is pressed, WM_HELP is sent to the
'window associated with the menu; otherwise, WM_HELP is sent to
'the window that has the keyboard focus. If no window has the
'keyboard focus, WM_HELP is sent to the currently active window.
 
'Primary Code:
CallBack Function DlgProc() As Long
   Select Case CB.Msg
      Case %WM_Help
         'response goes here
   End Select
End Function
 
 
'Compilable Example:
'this example opens the gbSnippets Help file when F1 is pressed
#Compile Exe
#Dim All
#Include "Win32API.inc"
Global hDlg as DWord
%IDC_Button = 100
Function PBMain() As Long
   Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
   Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
   Local tempFile As Asciiz * %Max_Path, iReturn as Long
   Select Case CB.Msg
      Case %WM_Help        'sent in response to pressing F1
         tempFile = Exe.Path$ + "support_files\gbsnippets.chm"  
         iReturn = ShellExecute(hDlg, "Open", tempFile, $Nul, $Nul, %SW_ShowNormal) 'bring up Help file contents
   End Select
End Function
 
'gbs_00038
 


created by gbSnippets: http://www.garybeene.com