Is it possible to change the background color of a CMFCButton which is under control of a visual manager theme?
-
(this is partly a rant, because it seems to be something really easy to do, but the framework makes it really hard to achieve). I need to be able to change the background color of a CMFCButton when certain conditions happen in our application. According to the documentation, I could use the method
CMFCButton::SetFaceColor
(Sets the background color for the button text); but this will get overridden (sp?) by the visual manager drawing method (CMFCBaseVisualManager::DrawPushButton
) and will have not effect. Our application is under control of a CMFCVisualManager theme; so all controls are drawn to respect the current theme ( we want to have themes in our application). There is a static method in CMFCButton to disable themes for ALL CMFCButtons; so that is a little bit overkill. I could set the CMFCButton flag m_bDontUseWinXPTheme to TRUE (which will disable the theme for that particular button (I would need to inherit from CMFCButton) But that will change the look of the button (and if I want to keep some of the look, I would have to draw all of it manually). Any insights, tips or hints on what would be the best way to change the background color of a CMFCButton without having to re-invent the wheel? Thanks. Max.I'd rather be phishing!
-
(this is partly a rant, because it seems to be something really easy to do, but the framework makes it really hard to achieve). I need to be able to change the background color of a CMFCButton when certain conditions happen in our application. According to the documentation, I could use the method
CMFCButton::SetFaceColor
(Sets the background color for the button text); but this will get overridden (sp?) by the visual manager drawing method (CMFCBaseVisualManager::DrawPushButton
) and will have not effect. Our application is under control of a CMFCVisualManager theme; so all controls are drawn to respect the current theme ( we want to have themes in our application). There is a static method in CMFCButton to disable themes for ALL CMFCButtons; so that is a little bit overkill. I could set the CMFCButton flag m_bDontUseWinXPTheme to TRUE (which will disable the theme for that particular button (I would need to inherit from CMFCButton) But that will change the look of the button (and if I want to keep some of the look, I would have to draw all of it manually). Any insights, tips or hints on what would be the best way to change the background color of a CMFCButton without having to re-invent the wheel? Thanks. Max.I'd rather be phishing!
Alas, think your only solution is to derive your own button from the MFC one and change the OnDraw() method (think that's what the draw method is called, going off memory). I had to do this for a set of buttons that reflected status on their color. It's not terribly hard to do once you've done it once.
-
(this is partly a rant, because it seems to be something really easy to do, but the framework makes it really hard to achieve). I need to be able to change the background color of a CMFCButton when certain conditions happen in our application. According to the documentation, I could use the method
CMFCButton::SetFaceColor
(Sets the background color for the button text); but this will get overridden (sp?) by the visual manager drawing method (CMFCBaseVisualManager::DrawPushButton
) and will have not effect. Our application is under control of a CMFCVisualManager theme; so all controls are drawn to respect the current theme ( we want to have themes in our application). There is a static method in CMFCButton to disable themes for ALL CMFCButtons; so that is a little bit overkill. I could set the CMFCButton flag m_bDontUseWinXPTheme to TRUE (which will disable the theme for that particular button (I would need to inherit from CMFCButton) But that will change the look of the button (and if I want to keep some of the look, I would have to draw all of it manually). Any insights, tips or hints on what would be the best way to change the background color of a CMFCButton without having to re-invent the wheel? Thanks. Max.I'd rather be phishing!
-
Have you looked at https://msdn.microsoft.com/en-us/library/bb983031.aspx[^]?
Thanks, That was just too easy... :~
I'd rather be phishing!
-
Alas, think your only solution is to derive your own button from the MFC one and change the OnDraw() method (think that's what the draw method is called, going off memory). I had to do this for a set of buttons that reflected status on their color. It's not terribly hard to do once you've done it once.
Thanks, That was just too easy... :~
I'd rather be phishing!
-
Thanks, That was just too easy... :~
I'd rather be phishing!
-
I hate to say this, but I never cease to be amazed at the number of questions I manage to answer just by looking at the documentation.
I know. When I originally looked at OnDraw, I did not want to use it because I expected to have to redraw everything (inner, outer, fill, text and theme support) But it ended up to look something like:
OnDrawn(...)
{
if (condition)
pDC->FillRect(...);
else
pDC->FillRect(...);__super::OnDraw(...)
}I'd rather be phishing!