Date: 02-16-2022
Return to Index
created by gbSnippets
'Returns handle to window/control with keyboard focus
'Primary Code:
iResult& = GetFocus
'Compilable Example: (Jose Includes)
#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 Button, hDlg, 100,"Set Focus", 50,10,100,20
Control Add TextBox, hDlg, 200,"TextBoxA", 50,40,100,20
Control Add TextBox, hDlg, 300,"TextBoxB", 50,70,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case CB.Msg
Case %WM_SetCursor
Local iResult&
Select Case GetFocus
Case GetDlgItem(hDlg,100) : Control Set Text hDlg, 100, "Label has focus"
Case GetDlgItem(hDlg,200) : Control Set Text hDlg, 100, "TextBoxA has focus"
Case GetDlgItem(hDlg,300) : Control Set Text hDlg, 100, "TextBoxB has focus"
End Select
End Select
End Function
'gbs_00024
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm