#PBForms Created
'--------------------------------------------------------------------------------
'Hotkey1.bas
'Program to test the "msctls_hotkey32" control
'Allows you to set a hotkey (CTRL, SHIFT, ALT + ...)
'Hotkey is detected here by checking the SC_HOTKEY message,
'RegisterHotkey is not used here.
'Notice the difference with the other routine, that DOES use
'RegisterHotkey, when hotkey is invoked
'--------------------------------------------------------------------------------
#Compile Exe
#
Dim All
#Include "Win32Api.Inc"
Global ghDlg
As Dword
'--------------------------------------------------------------------------------
' ** Includes **
'--------------------------------------------------------------------------------
#PBForms Begin Includes
#
If Not %Def(%WINAPI)
#Include "WIN32API.INC"
#EndIf
#
If Not %Def(%COMMCTRL_INC)
#Include "COMMCTRL.INC"
#EndIf
#Include "PBForms.INC"
#PBForms
End Includes
'--------------------------------------------------------------------------------
'--------------------------------------------------------------------------------
' ** Constants **
'--------------------------------------------------------------------------------
#PBForms Begin Constants
%IDD_DIALOG1 = 101
%IDC_LABEL1 = 1001
%IDC_MSCTLS_HOTKEY32 = 1002
%IDC_LABEL2 = 1003
%IDC_ActivateHotkey = 1004
#PBForms
End Constants
'--------------------------------------------------------------------------------
'--------------------------------------------------------------------------------
' ** Declarations **
'--------------------------------------------------------------------------------
Declare CallBack
Function ShowDIALOG1Proc()
Declare Function ShowDIALOG1(
ByVal hParent
As Dword)
As Long
#PBForms Declarations
'--------------------------------------------------------------------------------
'--------------------------------------------------------------------------------
Function PBMain()
PBFormsInitComCtls (%ICC_WIN95_CLASSES
Or %ICC_DATE_CLASSES
Or %ICC_INTERNET_CLASSES)
ShowDIALOG1 %HWND_DESKTOP
End Function
'--------------------------------------------------------------------------------
'--------------------------------------------------------------------------------
' ** CallBacks **
'--------------------------------------------------------------------------------
CallBack
Function ShowDIALOG1Proc()
Local hHotKeyControl
As Long
Local wHotKey
As Word
Static nAtom
As Dword
Select Case CbMsg
Case %WM_INITDIALOG
Case %WM_DESTROY
Case %WM_SYSCOMMAND
If CbWParam = %SC_HOTKEY
Then
MsgBox "OK! it worked!"
End If
Case %WM_COMMAND
Select Case CbCtl
Case %IDC_ActivateHotkey
If CbCtlMsg = %BN_CLICKED
Or CbCtlMsg = 1
Then
Control Handle ghDlg, %IDC_MSCTLS_HOTKEY32
To hHotKeyControl
wHotKey = SendMessage(hHotKeyControl, %HKM_GETHOTKEY, 0, 0)
SendMessage ghDlg, %WM_SETHOTKEY, wHotKey, 0
End If
End Select
End Select
End Function
'--------------------------------------------------------------------------------
'--------------------------------------------------------------------------------
' ** Dialogs **
'--------------------------------------------------------------------------------
Function ShowDIALOG1(
ByVal hParent
As Dword)
As Long
Local lRslt
As Long
Local a
As String
#PBForms Begin Dialog %IDD_DIALOG1->->
Local hDlg
As Dword
 

ialog
New hParent, "Hotkey test", 103, 72, 233, 170, %WS_POPUP
Or _
%WS_BORDER
Or %WS_DLGFRAME
Or %WS_SYSMENU
Or %WS_MINIMIZEBOX
Or _
%WS_MAXIMIZEBOX
Or %WS_CLIPSIBLINGS
Or %WS_VISIBLE
Or %DS_MODALFRAME
Or _
%DS_3DLOOK
Or %DS_NOFAILCREATE
Or %DS_SETFONT, %WS_EX_WINDOWEDGE
Or _
%WS_EX_CONTROLPARENT
Or %WS_EX_LEFT
Or %WS_EX_LTRREADING
Or _
%WS_EX_RIGHTSCROLLBAR,
To hDlg
Control Add Label, hDlg, %IDC_LABEL1, "Label1", 6, 6, 216, 104, %WS_CHILD
Or _
%WS_VISIBLE
Or %WS_BORDER
Or %SS_LEFT, %WS_EX_STATICEDGE
Or %WS_EX_LEFT _
Or %WS_EX_LTRREADING
Control Add "msctls_hotkey32", hDlg, %IDC_MSCTLS_HOTKEY32, _
"msctls_hotkey321", 98, 122, 78, 12, %WS_CHILD
Or %WS_VISIBLE, _
%WS_EX_CLIENTEDGE
Or %WS_EX_LEFT
Or %WS_EX_LTRREADING
Control Add Label, hDlg, %IDC_LABEL2, "Click and hit keys -->", 10, 122, 82, _
12, %WS_CHILD
Or %WS_VISIBLE
Or %SS_RIGHT, %WS_EX_LEFT
Or _
%WS_EX_LTRREADING
Control Add Button, hDlg, %IDC_ActivateHotkey, "Activate hotkey", 98, 140, _
64, 14
#PBForms
End Dialog
ghDlg = hDlg
a = a & "
Step 1: Click the hotkey control (looks like an edit box..)" & $CrLf
a = a & "
Step 2: Press a hotkey combination (CTRL T or something)" & $CrLf
a = a & "
Step 3: Click
'Activate hotkey'" & $CrLf
a = a & "
Step 4: Press the hotkey combination you entered (CTRL T or something) and see what happens" & $CrLf
a = a & "
Step 5: Start again from step 1 if you want" & $CrLf & $CrLf
a = a & "Minimize the window and press hotkey again a few time. See the difference." & $CrLf
Control
Set Text ghDlg, %IDC_LABEL1, a
 

ialog Show Modal ghDlg,
Call ShowDIALOG1Proc
To lRslt
Function = lRslt
End Function