Solved

Changing Radio Button Text color

Posted on 2001-06-05
9
4,010 Views
Last Modified: 2013-11-20
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

0
Comment
Question by:KaplanDani
9 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 100 total points
ID: 6158222
There are several implementations fo so-called "hover buttons" here:

http://codeguru.earthweb.com/buttonctrl/index.shtml

This one looks particularly promising:
http://codeguru.earthweb.com/buttonctrl/hover_button.shtml

But it looks like they all make you create several bitmaps (ala web page mouse-over buttons).

It sound like you have already created a class for the hover buttons.  I think that all you need to do is add a message map entry for handler for that class.

ON_WM_CTLCOLOR_REFLECT()

and a hndler like so:

HBRUSH CMyRadioBtn::CtlColor(CDC* pDC, UINT nCtlColor)
{
   if ( nCtlColor= nIdTheButtonBeingHovered ) {
     // set the hover colors
   }
   else {
     // set the non-hover colors
   }
   return NULL;    // (or brush to use)
}

-- Dan
0
 
LVL 2

Author Comment

by:KaplanDani
ID: 6160470
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.
0
 

Expert Comment

by:alortiz
ID: 6160847
The propperties you are looking for, are inherited from CWindow
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6161105
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

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:jizhang
ID: 6182047
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
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6320342
hi for KaplanDani,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6686656
hi for KaplanDani,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
LVL 11

Expert Comment

by:griessh
ID: 7202168
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
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7220553
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
conditional code and condition difference 9 76
mapAB Challlenge 35 123
firstChar challenge 13 106
Message not shown 5 29
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now