15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Set background color of a Droplist-ComboBox

Karl Lukas -- lukas@deos.ch
Friday, August 16, 1996

Environment: NT 4.0, VC++ 4.1

I'm trying to change the background color of the edit portion of a
CComboBox of type 'Droplist'. I tried the following code, which
works fine with Dropdown-ComboBoxes, but unfortunately not 
with Droplists:

HBRUSH CDOSTICombo::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	pDC -> SetTextColor(m_crTextColor);
	pDC -> SetBkMode (TRANSPARENT);
	return (HBRUSH)*m_pBrush;  // Brush containing background color
}

Does anybody know how to do this?
Thanks,
Karl




Kostya Sebov -- sebov@is.kiev.ua
Monday, August 19, 1996

>   Environment: NT 4.0, VC++ 4.1
>
>   I'm trying to change the background color of the edit portion of a
>   CComboBox of type 'Droplist'. I tried the following code, which
>   works fine with Dropdown-ComboBoxes, but unfortunately not
>   with Droplists:
>
>   HBRUSH CDOSTICombo::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
>   {
>       pDC -> SetTextColor(m_crTextColor);
>       pDC -> SetBkMode (TRANSPARENT);
>       return (HBRUSH)*m_pBrush;  // Brush containing background color
>   }
>
>   Does anybody know how to do this?
>   Thanks,
>   Karl
>
>
Droplist combos do NOT have edit window portion. That is the static portion they
have is actually a part of the control. It is painted, hit-tested, etc. directly
by the combo's HWND.

To customize the appearance of the droplist combo's static portion you'll have
to make it owner-draw and render if in the DrawItem overridable. Note that in
this case you'll also have to draw the list portion's items.


--- 
Kostya Sebov. 
----------------------------------------------------------------------------
Tel: (38 044) 266-6387 | Fax: (38 044) 266-6195 | E-mail: sebov@is.kiev.ua




| Вернуться в корень Архива |