I want my program to know, when the user changes the focus, e.g. by pressing the TAB key or by cklicking at a gadget with the mouse. In the docs, I found constants such as
Code: Select all
#PB_Event_Menu
#PB_Event_Gadget
Now I've found out, that 49331 seems to work for that purpose, at least here on Windows XP.
Code: Select all
; Window Constants
Enumeration
#WinMain
EndEnumeration
; Gadget Constants
Enumeration
#ListIcon
#BtnCheckAll
#BtnSelect
EndEnumeration
Define Event, Count
If OpenWindow(#WinMain, 100, 100, 250, 170, "Focus test") = 0
MessageRequester("Error", "OpenWindow() failed.")
End
EndIf
ListIconGadget(#ListIcon, 5, 5, 240, 110, "", 30, #PB_ListIcon_CheckBoxes | #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(#ListIcon, 1, "", 100)
AddGadgetColumn(#ListIcon, 2, "", 100)
ButtonGadget(#BtnCheckAll, 10, 130, 100, 25, "Button A")
ButtonGadget(#BtnSelect, 130, 130, 100, 25, "Button B")
AddGadgetItem(#ListIcon, -1, "" + #LF$ + "Peter" + #LF$ + "Smith")
AddGadgetItem(#ListIcon, -1, "" + #LF$ + "Mary" + #LF$ + "Meyer")
AddGadgetItem(#ListIcon, -1, "" + #LF$ + "Jolly" + #LF$ + "Jumper")
SetGadgetState(#ListIcon, 0)
SetActiveGadget(#ListIcon)
Count = 0
Repeat
Event = WaitWindowEvent()
Select Event
Case 49331
Count + 1
Debug "Focus change #" + Str(Count)
EndSelect
Until Event = #PB_Event_CloseWindow
I also tried using EventType() and GetActiveGadget(), but to no avail.
TIA, Little John