Link to home
Start Free TrialLog in
Avatar of KaplanDani
KaplanDani

asked on

Changing Radio Button Text color

I wish to change the color of the textof a radio button when the mouse is aronud it.
I catch the WM_MOUSEMOVE and then I set focus on the button. yet I can't find the way to change the button color, and how to make the background of the button transparent (I wish only the text and the radio circle to be visiable)

The button was derived from CButton , and is created on a dialogbox with create function, during oninitialize, with radio button style.

I've tried to catch WM_CTLCOLOR in the dialog class (the parnet of the buttons) but if I set the Button's text color there, it sets all the radio buttons I've created inspite the if statement I put there to change only a single button. (the if works since I've notice that if I change the first button it effects all the rest and if I change the 2nd, none are effected).
the SetBKmode(Transparent) did nothing to the buttons.

So basicly I need 2 things - the change text color, and how to make the background transparent.

thanks in advance.

Dani

ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KaplanDani
KaplanDani

ASKER

There is no ON_WM_CTLCOLOR_REFLECT on the MSDN.
I've found how to chnage the radio button text color - I set the style to BS_OWNERDRAW and the ctlcolor works.
But still I need to find a way to make the background transparent.
(i want to see only text and a circle).
The site you quoted uses load bitmap and I don't want to use that method.
The propperties you are looking for, are inherited from CWindow
oops, ON_WM_CTLCOLOR_REFLECT is obsolete

I found it in..
http://msdn.microsoft.com/library/periodic/period96/S1DCC.htm

details about it hare here:

HOWTO: Change the Color of an MFC Child Control Class
http://support.microsoft.com/support/kb/articles/Q132/0/80.asp

To do transparent drawing, try setting

CDC.SetBkMode( TRANSPARENT );

-- Dan

Hi there,

If you want to set a BT text a color,  you need to
tell which BT --   swich  GetDlgCtrlID() {case ..};

For example, set BT 1,3,5:

HBRUSH CAboutDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
     HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
     
     // TODO: Change any attributes of the DC here
     int nID = pWnd->GetDlgCtrlID();
        switch (nID)
        {
        case IDC_RADIO1:
                pDC->SetTextColor(RGB(0xff, 0, 0));
                break;
        case IDC_RADIO3:
                pDC->SetTextColor(RGB(0, 0, 0xff));
                break;
        case IDC_RADIO5:
     pDC->SetTextColor(RGB(0,0xff,0));
     break;
     default:
     break;
        }
     
     // TODO: Return a different brush if the default is not desired
     return hbr;
}

Ji Zhang
hi for KaplanDani,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
hi for KaplanDani,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
Unless there is objection or further activity,  I will suggest to accept

     "DanRollins"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
Force accepted

** Mindphaser - Community Support Moderator **