Click to See Complete Forum and Search --> : Need some help with OnCtlColor please...


kishk91
September 17th, 1999, 04:14 PM
yoo gurus....
can you please help me with lil something here?
i have dialog base app and this is my OnCtlColor class..

HBRUSH CDlgClass::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
//pDC->SetTextColor(RGB(0,0,255));

if(pWnd==GetDlgItem(IDC_RADIO1))
pDC->SetTextColor(RGB(255,0,0));//this dosent work why?

return hbr;
}




now i wanna set diffrent colors for some controls
but it dosent work...
any ideas guys??

and my second question is how can i change the color of the conrol (radio buttons and check boxes) when the mouse is over them??
thanks in advance
kishk91


kishk91@hotmail.com
http://www.path.co.il
ICQ: 13610258

Tom Lee
September 17th, 1999, 04:17 PM
HBRUSH CCHXServerConfig::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
switch(nCtlColor)
{
case CTLCOLOR_LISTBOX:
case CTLCOLOR_EDIT:
// Set color to green on black and return the backgroundbrush.
pDC->SetTextColor(RGB(0, 255, 0));
pDC->SetBkColor(RGB(96, 96, 96));
return (HBRUSH)(m_pEditBackgroundColor->GetSafeHandle());
case CTLCOLOR_STATIC:
pDC->SetTextColor(RGB(255, 0, 0));
pDC->SetBkColor(RGB(192, 192, 128));
return (HBRUSH)(m_pDialogColor->GetSafeHandle());
case CTLCOLOR_BTN:
pDC->SetTextColor(RGB(255, 0, 0));
pDC->SetBkColor(RGB(192, 192, 128));
return (HBRUSH)(m_pButtoncolor->GetSafeHandle());
case CTLCOLOR_DLG:
return (HBRUSH)(m_pDialogColor->GetSafeHandle());
}

return (HBRUSH)(m_pButtoncolor->GetSafeHandle());
}

kishk91
September 17th, 1999, 04:25 PM
ok.. this will change all the static control to some color and so on..
but what if i have IDC_RADIO1 IDC_RADIO2 and IDC_RADIO3
how do i change the color of IDC_RADIO1 only..
?

kishk91@hotmail.com
http://www.path.co.il
ICQ: 13610258

September 17th, 1999, 04:33 PM
Sounds to me like you should do owner draw for your radio buttons. That means handling owner draw and measure item messages.

kishk91
September 17th, 1999, 04:41 PM
ok.. but i use the dialog boxes editor...
and in the properties of the controls i dont have
owner draw option...
so how do i handle this??


kishk91@hotmail.com
http://www.path.co.il
ICQ: 13610258

jase jennings
March 6th, 2001, 03:38 PM
Hi
I have the same problem that you had here. Did you fix it ? Can you help me?

Jase

<no witty trailer supplied>