Control "lost focus" message

Windows specific forum
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Control "lost focus" message

Post by milan1612 »

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
Windows 7 & PureBasic 4.4
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

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 = 16
:?:
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

Actually I didn't see it :?: :?: :?:
What's going on with me :oops:
Thanks anyway :D
Windows 7 & PureBasic 4.4
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

LOL no problem! Image
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

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
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

That's quite exactly that what I tried to do :D
Windows 7 & PureBasic 4.4
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

milan1612 wrote:That's quite exactly that what I tried to do :D
;)

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 
That's all ya need then !
JCV
Enthusiast
Enthusiast
Posts: 580
Joined: Fri Jun 30, 2006 4:30 pm
Location: Philippines

Post by JCV »

Thats nice.
Added more fancy on my project. :lol:

[Registered PB User since 2006]
[PureBasic 6.20][SpiderBasic 2.2]
[RP4 x64][Win 11 x64][Ubuntu x64]
Post Reply