|
-
November 27th, 2014, 03:45 AM
#5
Re: Change text and bkg color of CComboBox
Yes, is working now 
Here is the code:
Code:
CMyComboBox::CMyComboBox()
{
m_Brush.CreateSolidBrush(RGB(255, 0, 0));
}
CMyComboBox::~CMyComboBox()
{
m_Brush.DeleteObject();
}
BEGIN_MESSAGE_MAP(CMyComboBox, CComboBox)
//{{AFX_MSG_MAP(CMyComboBox)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyComboBox message handlers
BOOL CMyComboBox::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult)
{
// TODO: Add your specialized code here and/or call the base class
if(WM_CTLCOLOREDIT != message)
return CComboBox::OnChildNotify(message, wParam, lParam, pLResult);
HDC hdcChild = (HDC)wParam;
if(NULL != hdcChild)
{
SetBkMode(hdcChild, TRANSPARENT);
SetTextColor(hdcChild, RGB(255, 255, 0));
SetBkColor(hdcChild, RGB(255, 0, 0));
*pLResult = (LRESULT)(m_Brush.GetSafeHandle());
}
return TRUE;
// return CComboBox::OnChildNotify(message, wParam, lParam, pLResult);
}
I still have a question: yes, the text and bkg color is changed now when combobox has CBS_DROPDOWNLIST style, but this solution doesn't change text and bkg color when combobox has CBS_DROPDOWN style ...
so, when combobox has CBS_DROPDOWN style, I should change text and bkg color through OnCtlColor handler, and when combobox has CBS_DROPDOWNLIST style I should override OnChildNotify ? Am I right ?
Last edited by mesajflaviu; November 27th, 2014 at 04:35 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|