Hi there.

In a little program, I am writing, I colorize my controls (background, Textcolor).

I managed to colorize the edit boxes and the static fields, and my window is nicely skinned.

However, on the combobox, the WM_CTLCOLOREDIT message doesn't work. It doesn't react on it.
The Listbox of the combobox reacts just fine to WM_CTLCOLORLISTBOX.

Does someone know, how to colorize the edit field of the combobox?

Greets YaWNS
Posted on 2002-08-29 18:50:24 by YaWNS
WM_CTLCOLOREDIT is sent to the parent of the edit control. In this case, the parent is the ComboBox window. So I guess you would need to subclass the combobox and intercept the WM_CTLCOLOREDIT through there.
Posted on 2002-08-30 00:08:44 by comrade
maybe this will be usefull for somebody....

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

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

...and you need to subclass the ComboBox control and process the WM_CTLCOLORLISTBOX for the drop down list

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
Posted on 2006-04-12 08:15:17 by diablo2oo2
I use GetComboBoxInfo which returns the 3 separate handles in a COMBOBOXINFO. I then color each part of the combo separately.
Posted on 2006-04-15 13:07:19 by msmith
This is exactly what i m looking for but haven't been successful

The WM_CTLCOLORLISTBOX makes the droped list to be colored but the edit field part remains same  :sad:

Posted on 2006-10-05 12:41:01 by sonic
You can always do an owner drawn combo box, here is the relevant code to add to the message loop. The source and example is available at my website (ODCombo.zip)

mov edi,
cmp D,1001
mov B,0
mov eax,
jz >
invoke SetTextColor,,000000FFh
mov ecx,edi
invoke FillRect,,ecx,
jmp >.DRAWIT
invoke SetTextColor,,00FF0000h
invoke GetStockObject,WHITE_BRUSH
mov ecx,edi
invoke FillRect,,ecx,eax
invoke SetBkMode,,TRANSPARENT

mov eax,
or eax,eax
js >
invoke SendMessage,,CB_GETLBTEXT,\
,OFFSET TextBuffer
invoke SendMessage,,WM_GETTEXT,256,\
OFFSET TextBuffer
mov eax,edi
invoke DrawText,,OFFSET TextBuffer,-1,\
xor eax,eax
inc eax

; Measurements for the combo box
mov edi,
cmp D,1001
;Find the DC for the combo box and get the text height
invoke GetDlgItem,,
mov ebx,eax ; EBX holds the Handle
invoke GetDC,eax
mov esi,eax ; ESI holds the DC
; Just get the height for a single item
; Owner drawn fixed only sends the message once
; so it really makes no difference what text we use
invoke GetTextExtentPoint32,esi,"Hello",5,OFFSET pt
; Release the DC
invoke ReleaseDC,ebx,esi
mov eax,
mov D,eax
xor eax,eax
inc eax
Posted on 2006-10-05 22:16:44 by donkey
Thanks for reply donkey...You are always very helpful...I will read that....Manwhile after spending few hours i got it....
Only one additional line was needed

invoke SetbkColor,wparam,color

hehehe...i m improving  :P
Posted on 2006-10-06 09:18:14 by sonic