Change the color on CButton ? 
Author Message
 Change the color on CButton ?

I am trying to change the color of a button on a dialog box; I have used
the OnCtlColor function to change the color of a CButton object; it does
'nt work as I have expected it to.

I am aware that the windows standard is to set a button to the color
dependant on the
current desktop scheme; however because of the way I am writing the user
interface,
I am having to change the control colors. I have had some success
re-writing the whole
CButton class as derived from CWnd.  Are there any other ways of doing this
without
writing the complete CButton class ?.



Fri, 28 Apr 2000 03:00:00 GMT  
 Change the color on CButton ?

The only way to change the color of a button is to make it Owner Drawn and
draw it yourself  (perhaps you can use CBitmapButton)

--
Why isn't there mouse-flavored cat food?
 ---------------------------------------------------------------------------
---
| Author for Pinnacle Publishing "Visual C++ Developer"
http://www.pinpub.com/ |
| http://lucifer.lotus.com/jim/main.htm
|
 ---------------------------------------------------------------------------
---



Fri, 28 Apr 2000 03:00:00 GMT  
 Change the color on CButton ?

Quote:

> I am trying to change the color of a button on a dialog box; I have used
> the OnCtlColor function to change the color of a CButton object; it does
> 'nt work as I have expected it to.

> I am aware that the windows standard is to set a button to the color
> dependant on the
> current desktop scheme; however because of the way I am writing the user
> interface,
> I am having to change the control colors. I have had some success
> re-writing the whole
> CButton class as derived from CWnd.  Are there any other ways of doing this
> without
> writing the complete CButton class ?.

Try defining your buttons as CBitmapButtons
--
Rob Goudvis




Sat, 29 Apr 2000 03:00:00 GMT  
 Change the color on CButton ?

Quote:

> I am trying to change the color of a button on a dialog box; I have used
> the OnCtlColor function to change the color of a CButton object; it does
> 'nt work as I have expected it to.

> I am aware that the windows standard is to set a button to the color
> dependant on the
> current desktop scheme; however because of the way I am writing the user
> interface,
> I am having to change the control colors. I have had some success
> re-writing the whole
> CButton class as derived from CWnd.  Are there any other ways of doing this
> without
> writing the complete CButton class ?.

I do this by deriving a class from CButton called CCustButton.  The
derived class has variables for button color, font color, and font.  If
the create call does not specify a BS_OWNERDRAW, the derived class
simply calls the base class functions.  Manully drawing a button is
relativety simple and is better than using CBitmapButton unless the
button is a bitmap button.  

The CCustButton::OnDraw() function simply draws a rectangle with the
specified button color for a brush, draws the text with the specified
font and color, draws two white lines on the left and top and two black
lines on the right and bottom if the button is up or reverse the colors
if the button is depressed.  You will also have to draw the focus
rectangle if the button has focus.

Add a couple of member functions to your derived class to set the button
color and set the button font.

Mike Settles



Tue, 02 May 2000 03:00:00 GMT  
 Change the color on CButton ?

The easy way to change a button is to use CBitmapButton in which you have to
supply the bitmaps for buttons in different states. Sometimes just these few
button states are still not good enough and in that case you can ovriwrite the
CButton::DrawItem  in which you basically have to draw the button yourself with a
hDC.

Tom

Quote:


> > I am trying to change the color of a button on a dialog box; I have used
> > the OnCtlColor function to change the color of a CButton object; it does
> > 'nt work as I have expected it to.

> > I am aware that the windows standard is to set a button to the color
> > dependant on the
> > current desktop scheme; however because of the way I am writing the user
> > interface,
> > I am having to change the control colors. I have had some success
> > re-writing the whole
> > CButton class as derived from CWnd.  Are there any other ways of doing this
> > without
> > writing the complete CButton class ?.
> Try defining your buttons as CBitmapButtons
> --
> Rob Goudvis





Wed, 03 May 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Change CButton color and CButton text color in CDialog

2. how do I change the color of CButton???

3. Change background color of CButton

4. Change Text color in CButton?

5. As change the color of CButton and of a Check_Box in time of execution...?

6. As change the color of CButton and of a Check_Box in time of execution...?

7. As change the color of CButton and of a Check_Box in time of execution...?

8. Change Color of CButton, CEdit and so on

9. CButton Change color of disabled radio button

10. How can I change color of CButton

11. How to change the color of a CButton

12. Change background and text color in CButton

 

 
Powered by phpBB® Forum Software