|
-
June 21st, 2004, 01:59 AM
#1
Onctrlcolor() paint a button
How do i paint a button Red ?
i know that i must use OnCtrlColor , but i don't know what to write there.
How do i call the OnCtrlColor() when the program already runs ?
( i know that the OnCtrlColor function is called in the beggining of the program).
-
June 21st, 2004, 02:04 AM
#2
Check out thesearticles...
-
June 21st, 2004, 02:33 AM
#3
'CButton' is the only control that does not respond to the 'OnCtlColor()' message handler even though the MSDN (http://msdn.microsoft.com) explains it that way. To change the color of a 'CButton' control you have to set the style to ownerdrawn and do it yourself.
You will find a complete 'CColorButton' class here. This class does not allow you to change the color at run-time...you will find a modified control here.
-
June 21st, 2004, 02:33 AM
#4
Thanks Amit,but....
Thank you ,but these articles helps me to create a colored buttons, what i need is : How to change color of a button that i added to the FormView. and how do i change his color on runtime ( for example - when i push him i change his color )
i already tried :
CDC *pDC;
CButton *pButton1 = (CButton*) GetDlgItem(IDC_BUTTON1);
if ( pButton1 != NULL )
{
pDC = pButton1->GetDC();
pDC->SetBKColor(rgb(255,0,0);
}
GetDlgItem(IDC_BUTTON1)->RedrawWindow();
Why doesn't this work?
How do i paint a button ?
-
June 21st, 2004, 02:41 AM
#5
Use the link provided by Andreas. You can use any color button class by modifing it according to your needs but you have to ownerdraw buttons if you want to change their color at any time.
-
June 21st, 2004, 05:12 AM
#6
Thanks
Thank you for your help , i found the solution in the "Microsoft Form 2.0 CommandButton" it does it!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|