![]() |
|
QA: How to create a colored button?
By Nicholas Tsipanov, April 24, 2002.
QuestionI would like to have the buttons in my MFC application have the custom color. How could I do that? AnswerYou need to handle WM_CTLCOLOR in your button's parent window. MFC Wizard will create that handler for you. The framework will ask for color of every control in your window, you need to filter the requests for you control only.
After you've done this you face the problem with non-default behaviour of MFC buttons To workaround it create a simple CButton subclass that only overrides buggy OnLButtonDown behaviour:
Use CFixedButton class in your dialog or window whenever you need to non-standard behaviour of the button such as using custom color. SampleYou can download a sample application (12 Kb) that shows implementing of a colored button. DiscussDiscuss this article. Here you can write your comments and read comments of other developers. |
|||||||||||||||||||||