Jump to content
Tuts 4 You

Combobox Background Colour


Ziggy

Recommended Posts

I want to change the background colour of a ComboBox control.

For static and edit controls this can easily be done by handling the WM_CTLCOLORSTATIC or WM_CTLCOLOREDIT messages. But I don't know what to use for a ComboBox. WM_CTLCOLORLISTBOX doesn't work and a search hasn't turned up much of any use.

Any help appreciated please.

Z

Link to comment

Thanks diablo

Finally go it working with some trial and error.

Since a ComboBox has 2 parts - EditControl and DropDownList both need to be handled separately.

in the main windows message processing you need to

process the EDITCONTROL part of the ComboBox

.elseif uMsg==WM_CTLCOLOREDIT

mov eax, lParam

.if eax==hComboSelect ; ComboBox handle

invoke SetBkMode,wParam,TRANSPARENT; Background of Edit Text

RGB 0,0,0 ; black background or whatever color you want

invoke SetBkColor, wParam, eax

RGB TextRed, TextGreen, TextBlue ;eax = Text colour

invoke SetTextColor,wParam, eax ;set TextColor

invoke GetStockObject,NULL_BRUSH ;return a brush

ret

.endif

and you need to subclass the ComboBox control and process the WM_CTLCOLORLISTBOX

for the drop down list

.if uMsg==WM_CTLCOLORLISTBOX

invoke SetBkMode,wParam,TRANSPARENT ;Background of list Text

RGB TextRed, TextGreen, TextBlue ;eax = Text colour

invoke SetTextColor,wParam, eax ;set TextColor

invoke CreateSolidBrush, 00h ; black brush or whatever color you want

ret

.endif

Hope someone else finds this useful one day.

Z

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...