Click here to Skip to main content
15,844,155 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Can any one help me to set colors for different buttons?

Thanks in advance

sudhir.
Posted
Comments
cnvsudheerraju 21-Dec-11 6:51am    
i have to do in MFC with SDI only.. please replay ASAP.
Resmi Anna 21-Dec-11 7:10am    
Your buttons belong to CButton class rt?

1 solution

Please check the following url.
http://www.codeguru.com/cpp/controls/buttonctrl/article.php/c5157[^]

you can follow the tutorial and when it comes for different buttons, within the DrawItem() function check the control id and selct different colors accordingly. see below
C++
.......
switch( lpDrawItemStruct->CtlID )
{
case IDC_BUTTON1:
......
dc.FillSolidRect(rt, RGB(0, 0, 255));
......
case IDC_BUTTON2:
......
dc.FillSolidRect(rt, RGB(0, 255, 0));
.....
}
.....
 
Share this answer
 
v2
Comments
cnvsudheerraju 21-Dec-11 7:29am    
Thank you so much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900