Function Keys F1 - F12 |
Description
The function keys F1 thru F12 can now be trapped. Any combination with a shift key (like SHIFT, CTRL or ALT) is currently not supported, only the function keys by themselves. |
Example
Option Explicit Set oDlg = Wscript.CreateObject("WshDialog.Kit", "oDlg_") 'Add a new form and store a reference to it in the variable oFrm Set oFrm = oDlg.NewForm("") 'Set the form's caption oFrm.Caption = "Function Keys Example" 'Add a frame, named FRM1, to the form oFrm.NewFrame "FRM1", 300, 100, 3700, 1400, "" 'Add a label to the FRM1 frame sText = "This example demonstrates how to trap the" & vbCrlf sText = sText & "function keys F1 - F12 in WshDialog v1.04." & vbCrlf & vbCrlf sText = sText & "Please press the F1 key now ..." & vbCrlf & vbCrlf oFrm.NewLabel "TEXT", 200, 350, 3500, 1000, sText, "FRM1" 'Add an OK button and set it's Default property Set oCtl = oFrm.NewButton("EXIT", 1500, 1800, 1000, 375, "&Afsluiten") oCtl.Cancel = True 'Automatically size the form and show it (modally) oFrm.Autosize 'Enable event handling (callback) for this form oFrm.CallBack = True 'Show the form oFrm.Show vbModal '-------------------------------------------------------------------------------------------------- ' oDlg_ClickHandler handles the events sent by the controls '-------------------------------------------------------------------------------------------------- Sub oDlg_ClickHandler(sForm, sControl) Dim oFrm, oCtl 'Get a reference to the form and the control that raised the event Set oFrm = oDlg.Frm(sForm) Set oCtl = oFrm.Ctl(sControl) 'Check which 'control' caused the event Select Case UCase(sControl) Case "*F1" 'Handle the F1 key MsgBox "Hey, guess what? You pressed the F1 key!" Case "EXIT", "*CLOSE" 'The Exit button or closebox was clicked. Dismiss the form (hide it) oFrm.Hide Case Else 'Ignore all other events. Do NOT use oFrm.Hide here, 'or any event not handled above will dismiss the form End Select End Sub |