Detecting lostfocus type events from combobox gadgets
Posted: Tue Dec 02, 2003 11:11 pm
Code updated for 5.20+
Many thanks to fr34k as this is all his work!
Many thanks to fr34k as this is all his work!
Code: Select all
#Combo = 0
#Text = 1 ; to loose the focus to
Procedure.l Callback(Window, Message, wParam, lParam)
result = #PB_ProcessPureBasicEvents
If Message = #WM_COMMAND
If (wParam>>16) = #CBN_KILLFOCUS And lParam = GadgetID(#Combo)
Debug "Gadget lost focus"
ElseIf (wParam>>16) = #CBN_SETFOCUS And lParam = GadgetID(#Combo)
Debug "Gadget has focus"
EndIf
EndIf
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 400, 100, "ComboBox focus", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
SetWindowCallback(@Callback())
ComboBoxGadget(#Combo, 10, 10, 380, 300)
AddGadgetItem(#Combo, -1, "Item Number 0")
AddGadgetItem(#Combo, -1, "Item Number 1")
AddGadgetItem(#Combo, -1, "Item Number 2")
AddGadgetItem(#Combo, -1, "Item Number 3")
StringGadget(#Text, 10, 40, 380, 20, "")
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
End