[Windows] Coloring Comboboxes with images
Posted: Tue Mar 03, 2026 4:49 pm
I found some solutions in the forum showing how to color combobox gadgets, but none of these work with standard images. Complete custom drawing could be done but gets quite complicate when display scaling and some other aspects need to be taken into account.
Is there a (relatively simple) method to get colors also when using the #PB_ComboBox_Image flag?
Maybe there will be a possibility somewhen to get more and more gadget types colored by using the SetGadgetColor function, this would be wonderful.
Is there a (relatively simple) method to get colors also when using the #PB_ComboBox_Image flag?
Maybe there will be a possibility somewhen to get more and more gadget types colored by using the SetGadgetColor function, this would be wonderful.
Code: Select all
#DrawOpaque=$FF<<24
CreateImage(0,32,32,32)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0,0,32,32,#White)
Circle(15,15,15,#DrawOpaque|#Red)
StopDrawing()
If OpenWindow(0, 0, 0, 270, 180, "Combo Box Gadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ComboBoxGadget(0, 10, 10, 250, 40, #PB_ComboBox_Editable)
ComboBoxGadget(1, 10, 60, 250, 40, #PB_ComboBox_Image)
ComboBoxGadget(2, 10,110, 250, 40,#PB_ComboBox_Editable|#PB_ComboBox_Image)
For a = 0 To 8
For n=0 To 2
AddGadgetItem(n,a,"ComboBox "+Str(n)+", item " + Str(a+1),ImageID(0)*Bool(a&1))
Next n
Next a
For a = 0 To 2
SetGadgetState(a, 0)
SetGadgetColor(a,#PB_Gadget_FrontColor,#Blue)
SetGadgetColor(a,#PB_Gadget_BackColor,#Yellow)
Next a
Repeat
; ?
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf