Dear friends, any idea on how to change the foreground and background colors of a standard CBS_DROPDOWN (the one in which you can write) combobox (not the FWH one with a TGet on it)?
EMG
Dear friends, any idea on how to change the foreground and background colors of a standard CBS_DROPDOWN (the one in which you can write) combobox (not the FWH one with a TGet on it)?
EMG
Enrico,
Do you mean using FWH code ? Or in pure C ?
Any way will be fine.
EMG
Enrico,
Have a look to WM_CTLCOLORLISTBOX. It should be similar for a ComboBox.
Also, you have to consider that there is an Edit control (TGet in FWH) as a child of the combobox, so the combobox also has to answer to WM_CTLCOLORLISTBOX.
METHOD CtlColor( hWndChild, hDCChild ) CLASS TComboBox
if lAnd( GetWindowLong( ::hWnd, GWL_STYLE ), CBS_DROPDOWN )
SetTextColor( hDCChild, ::nClrText )
SetBkColor( hDCChild, ::nClrPane )
::hBkBrush = CreateSolidBrush( ::nClrPane )
return ::hBkBrush
endif
return nilEnrico,
Excellent, Master ![]()
What do you use ::hBkBrush for ? -you always call CreateSolidBrush()-
Antonio Linares wrote:Enrico,
Excellent, Master
What do you use ::hBkBrush for ? -you always call CreateSolidBrush()-
Enrico,
If you call CreateSolidBrush() always, then you can dinamically change the color of the control on the run.
Antonio,
So, are you suggesting we just do:
return CreateSolidBrush( ::nClrPane )
instead?
James
Antonio Linares wrote:Enrico,
If you call CreateSolidBrush() always, then you can dinamically change the color of the control on the run.
James Bott wrote:Antonio,
So, are you suggesting we just do:
return CreateSolidBrush( ::nClrPane )
instead?
James
Enrico,
Thanks for the explaination. This feature would be very useful if you wish to color the background different for required fields, then change it to white if the data is entered and vaild. You may remember me discussing this before.
James
Yes, but please notice that you can already do this with FWH dropdown comboboxes as they have a TGet on them. My coloring problem was about standard Windows dropdown comboboxes.
EMG