Date: 02-16-2022
Return to Index
created by gbSnippets
'The GetKeyState provides information about the state of the keys at the time
'an event took place. This is different from the API function GetAsyncKeyState,
'which gives the status of the keys at the time the API is called. Both
'return 0 if the key is not down.
'Primary Code:
iResult1& = GetKeyState(%vk_shift)
iResult2& = GetKeyState(%vk_control)
iResult1& = GetKeyState(%vk_menu) 'alt-key
'Compilable Example: (Jose Includes)
'This examples uses GetKeyState to check the status of the ALT
'key whenever at the time the button was pressed.
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Label, hDlg, 100,"", 50,10,100,20
Control Add Button, hDlg, 200,"Push", 50,40,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = 200 AND CB.Ctlmsg = %BN_Clicked Then
Local iResult&
iResult& = GetKeyState(%vk_menu) '0 if not pressed
Control Set Text hDlg, 100, Str$(iResult&)
End If
End Function
'gbs_00195
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm