Detecting lostfocus type events from combobox gadgets

Share your advanced PureBasic knowledge/code with the community.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Detecting lostfocus type events from combobox gadgets

Post by Karbon »

Code updated for 5.20+

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
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
freak
PureBasic Team
PureBasic Team
Posts: 5941
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

lol, i was just about to post that :mrgreen:

Timo
quidquid Latine dictum sit altum videtur
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

I'm SPEEDY FAST!

Thanks again, it's working like a charm!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Detecting lostfocus type events from combobox gadgets

Post by IdeasVacuum »

The code doesn't work in PB5.43LTS because #CBN_KILLFOCUS is unknown, but GetActiveGadget() can be used now.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply