Colouring the static-field in an un-editable ComboBox

Just starting out? Need help? Post your questions and find answers here.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

PB wrote:Anyone know how to do this with two or more ComboBoxGadgets?
Here is some example (just added some props) :

Code: Select all

Procedure ComboCallBack( hwnd.l, message.l, wParam.l, lParam.l ) 
  
  oldcombproc = GetProp_(hwnd.l, "OldProc")
  Result.l = CallWindowProc_(oldcombproc, hwnd, message, wParam, lParam ) 
  If Result
    If (message = #WM_CTLCOLOREDIT) Or (message = #WM_CTLCOLORLISTBOX) 
      SetBkMode_(wParam,#TRANSPARENT) 
      SetTextColor_(wParam,GetProp_(hwnd.l, "TextColor")) 
      SetBkColor_(wParam,GetProp_(hwnd.l, "BackColor")) 
      Result = GetProp_(hwnd.l, "BackBrush")
    ElseIf message = #WM_DESTROY 
      RemoveProp_(hwnd.l, "OldProc")
      RemoveProp_(hwnd.l, "TextColor")
      RemoveProp_(hwnd.l, "BackColor")
      DeleteObject_(GetProp_(hwnd.l, "BackBrush"))
      RemoveProp_(hwnd.l, "BackBrush")
    EndIf 
  EndIf
  
  ProcedureReturn Result 
  
EndProcedure 


OpenWindow( 0, 200,400,200,100, "Colorisation et Callback", #PB_Window_SystemMenu) 

CreateGadgetList( WindowID(0) ) 

ComboBoxGadget( 1, 10, 10, 180, 120, #PB_ComboBox_Editable ) 
AddGadgetItem(1, -1, "123" ) 
AddGadgetItem(1, -1, "456" ) 
AddGadgetItem(1, -1, "789" ) 
SetGadgetState(1,0) 


ComboBoxGadget( 2, 10, 60, 180, 120, #PB_ComboBox_Editable ) 
AddGadgetItem(2, -1, "123" ) 
AddGadgetItem(2, -1, "456" ) 
AddGadgetItem(2, -1, "789" ) 
SetGadgetState(2,0) 
  
SetProp_(GadgetID(1), "OldProc", SetWindowLong_(GadgetID(1), #GWL_WNDPROC, @ComboCallBack()) )
SetProp_(GadgetID(1), "TextColor", #White)
SetProp_(GadgetID(1), "BackColor", #Blue)
SetProp_(GadgetID(1), "BackBrush", CreateSolidBrush_(#Blue))

SetProp_(GadgetID(2), "OldProc", SetWindowLong_(GadgetID(2), #GWL_WNDPROC, @ComboCallBack()) )
SetProp_(GadgetID(2), "TextColor", #Red)
SetProp_(GadgetID(2), "BackColor", #White)
SetProp_(GadgetID(2), "BackBrush", CreateSolidBrush_(#White))

Repeat 
Until WaitWindowEvent() = #PB_Event_CloseWindow 
End
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Thanks gnozal, good example with the props. :)
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

srod asking a question?
now, THAT took my by surprise
(of course I have no clue what the question is all about)
I may not help with your coding
Just ask about mental issues!

http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
HarrysLad
User
User
Posts: 59
Joined: Fri Jun 04, 2010 9:29 pm
Location: Sunny Spain

Re: Colouring the static-field in an un-editable ComboBox

Post by HarrysLad »

An old thread but ...
Is it possible to set the foreground and/or background colours of a ComboBoxGadget?
This is not usually a problem but on one of my apps (and in Dark-Mode) I get a white foreground on a white background!

{edit:] this is on macOS. I should have mentioned that. :oops:

Dave
Post Reply