How to change color of push button
-
dear sir, i want to change background color of push buttons in my MFC program .how to change clor of buttons at run time
You can handle the CWnd::OnCtlColor / WM_CTLCOLOR message in your dialog class, and return a brush of your choice. Windows will then use that brush to paint the background of a control. Do a search for OnCtlColor in msdn, and it will even give sample functions. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cwnd.3a3a.onctlcolor.asp[^] Good luck, Iain.
-
You can handle the CWnd::OnCtlColor / WM_CTLCOLOR message in your dialog class, and return a brush of your choice. Windows will then use that brush to paint the background of a control. Do a search for OnCtlColor in msdn, and it will even give sample functions. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cwnd.3a3a.onctlcolor.asp[^] Good luck, Iain.
Iain Clarke wrote:
Do a search for OnCtlColor in msdn, and it will even give sample functions.
Sorry For Correcting you Sir, You can't Paint PushButton using OnCtlColor Handller
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV
-
dear sir, i want to change background color of push buttons in my MFC program .how to change clor of buttons at run time
aloktambi wrote:
i want to change background color of push buttons in my MFC program
You have to Create Owner Drawn Button PLUS Handle CButton::DrawItem(...)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV