Click here to Skip to main content
15,913,115 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How can I change background/text color of CComboBox ? Pin
Ozer Karaagac25-Mar-11 2:22
professionalOzer Karaagac25-Mar-11 2:22 
GeneralRe: How can I change background/text color of CComboBox ? Pin
_Flaviu25-Mar-11 2:46
_Flaviu25-Mar-11 2:46 
GeneralRe: How can I change background/text color of CComboBox ? Pin
Ozer Karaagac25-Mar-11 3:13
professionalOzer Karaagac25-Mar-11 3:13 
GeneralRe: How can I change background/text color of CComboBox ? Pin
_Flaviu25-Mar-11 2:59
_Flaviu25-Mar-11 2:59 
GeneralRe: How can I change background/text color of CComboBox ? Pin
Ozer Karaagac25-Mar-11 3:25
professionalOzer Karaagac25-Mar-11 3:25 
GeneralRe: How can I change background/text color of CComboBox ? Pin
Ozer Karaagac25-Mar-11 3:36
professionalOzer Karaagac25-Mar-11 3:36 
AnswerRe: How can I change background/text color of CComboBox ? Pin
వేంకటనారాయణ(venkatmakam)25-Mar-11 2:40
వేంకటనారాయణ(venkatmakam)25-Mar-11 2:40 
GeneralRe: How can I change background/text color of CComboBox ? Pin
_Flaviu25-Mar-11 6:03
_Flaviu25-Mar-11 6:03 
I solve the problem in the follow matter :
//    header
	CListBox m_ListBox;

//   implementation
	ON_WM_CTLCOLOR()

HBRUSH CComboBoxExt::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);

	// TODO: Change any attributes of the DC here

	if(nCtlColor == CTLCOLOR_EDIT)
	{
		if(m_Edit.GetSafeHwnd() == NULL)
		{
			m_Edit.SubclassWindow(pWnd->GetSafeHwnd());
		}
		if(! m_bAlertText)pDC->SetTextColor(COLOR_BLACK);
		else pDC->SetTextColor(COLOR_RED);
		if(! m_bAlertBkg)pDC->SetBkColor(COLOR_WHITE);
		else
		{
			pDC->SetBkColor(COLOR_ALERT);
			hbr = m_hBrushAlert;
		}
	}

	if(nCtlColor == CTLCOLOR_LISTBOX)
	{
		if(m_ListBox.GetSafeHwnd() == NULL)
		{
			m_ListBox.SubclassWindow(pWnd->GetSafeHwnd());
			m_pWndProc = reinterpret_cast<WNDPROC>(GetWindowLong(m_ListBox, GWL_WNDPROC));
			SetWindowLong(m_ListBox, GWL_WNDPROC, reinterpret_cast<long>(ComboBoxListBoxProc));
		}
		if(! m_bAlertBkg)pDC->SetBkColor(COLOR_WHITE);
		else
		{
			pDC->SetBkColor(COLOR_ALERT);
			hbr = m_hBrushAlert;
		}
	}

	pDC->SetBkMode(TRANSPARENT);

	// TODO: Return a different brush if the default is not desired

	return hbr;
}

I get handle of drop down list box in OnCtlColor

but I still have an question :
How can I change text / background color of edit while combo box have CBS_DROPDOWNLIST style ?
GeneralRe: How can I change background/text color of CComboBox ? Pin
_Flaviu25-Mar-11 21:27
_Flaviu25-Mar-11 21:27 
GeneralRe: How can I change background/text color of CComboBox ? Pin
mesajflaviu27-Mar-11 22:21
mesajflaviu27-Mar-11 22:21 
QuestionDelete a view Pin
john563224-Mar-11 3:03
john563224-Mar-11 3:03 
AnswerRe: Delete a view Pin
Albert Holguin24-Mar-11 4:24
professionalAlbert Holguin24-Mar-11 4:24 
GeneralRe: Delete a view Pin
john563224-Mar-11 19:45
john563224-Mar-11 19:45 
GeneralRe: Delete a view Pin
Albert Holguin25-Mar-11 3:48
professionalAlbert Holguin25-Mar-11 3:48 
AnswerRe: Delete a view Pin
Richard MacCutchan24-Mar-11 5:47
mveRichard MacCutchan24-Mar-11 5:47 
QuestionSTL : Map.Insert always sort the inserted key - How to prevent this Pin
pandit8424-Mar-11 0:35
pandit8424-Mar-11 0:35 
AnswerRe: STL : Map.Insert always sort the inserted key - How to prevent this Pin
Chris Losinger24-Mar-11 1:03
professionalChris Losinger24-Mar-11 1:03 
AnswerRe: STL : Map.Insert always sort the inserted key - How to prevent this Pin
Stefan_Lang30-Mar-11 1:51
Stefan_Lang30-Mar-11 1:51 
QuestionHow to reduce Flickering ? Pin
002comp23-Mar-11 22:47
002comp23-Mar-11 22:47 
AnswerRe: How to reduce Flickering ? Pin
CPallini23-Mar-11 23:00
mveCPallini23-Mar-11 23:00 
GeneralRe: How to reduce Flickering ? Pin
Maximilien24-Mar-11 2:56
Maximilien24-Mar-11 2:56 
GeneralRe: How to reduce Flickering ? Pin
CPallini24-Mar-11 4:27
mveCPallini24-Mar-11 4:27 
AnswerRe: How to reduce Flickering ? [modified] Pin
Cool_Dev24-Mar-11 0:22
Cool_Dev24-Mar-11 0:22 
GeneralRe: How to reduce Flickering ? Pin
Nitheesh George24-Mar-11 2:02
Nitheesh George24-Mar-11 2:02 
GeneralRe: How to reduce Flickering ? Pin
Albert Holguin24-Mar-11 4:26
professionalAlbert Holguin24-Mar-11 4:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.