How can I process a "Lost Focus" Event of a StringGadget?
I tried #WM_KILLFOCUS but didn't get it to work.
Has anybody tried that already?
Regards, milan1612
Control "lost focus" message
Control "lost focus" message
Windows 7 & PureBasic 4.4
- Fluid Byte
- Addict

- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Code: Select all
OpenWindow(0,0,0,400,300,"untitled",#WS_OVERLAPPEDWINDOW | 1)
CreateGadgetList(WindowID(0))
StringGadget(0,5,5,200,20,"lorem ipsum")
ButtonGadget(1,5,40,100,24,"screw u")
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget And EventType() = #PB_EventType_LostFocus
Debug "HAX0RS ON TEH PC!"
EndIf
Until EventID = 16Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
- Fluid Byte
- Addict

- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
-
Num3
- PureBasic Expert

- Posts: 2812
- Joined: Fri Apr 25, 2003 4:51 pm
- Location: Portugal, Lisbon
- Contact:
My sugar version...
Code: Select all
OpenWindow(0,0,0,400,300,"untitled",#WS_OVERLAPPEDWINDOW | 1)
CreateGadgetList(WindowID(0))
StringGadget(0,5,5,200,20,"lorem ipsum")
ButtonGadget(1,5,40,100,24,"screw u")
Procedure FocusText(gadget.l,focuscolor.l=$E2E3E1,unfocuscolor.l=$FFFFFF)
If GadgetType(gadget.l)=#PB_GadgetType_String
If EventType()=#PB_EventType_Focus
SetGadgetColor(gadget,#PB_Gadget_BackColor,focuscolor)
ElseIf EventType()=#PB_EventType_LostFocus
SetGadgetColor(gadget,#PB_Gadget_BackColor,unfocuscolor)
EndIf
EndIf
EndProcedure
Repeat
EventID = WaitWindowEvent()
EventGadget = EventGadget()
If EventID = #PB_Event_Gadget
FocusText(EventGadget)
If EventType() = #PB_EventType_LostFocus
Debug "HAX0RS ON TEH PC!"
EndIf
EndIf
Until EventID = 16-
Num3
- PureBasic Expert

- Posts: 2812
- Joined: Fri Apr 25, 2003 4:51 pm
- Location: Portugal, Lisbon
- Contact:
milan1612 wrote:That's quite exactly that what I tried to do
Code: Select all
Procedure FocusText(gadget.l,focuscolor.l=$E2E3E1,unfocuscolor.l=$FFFFFF)
If GadgetType(gadget.l)=#PB_GadgetType_String
If EventType()=#PB_EventType_Focus
SetGadgetColor(gadget,#PB_Gadget_BackColor,focuscolor)
ElseIf EventType()=#PB_EventType_LostFocus
SetGadgetColor(gadget,#PB_Gadget_BackColor,unfocuscolor)
EndIf
EndIf
EndProcedure 
