Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Is it possible to change the background color of a CMFCButton which is under control of a visual manager theme?

Is it possible to change the background color of a CMFCButton which is under control of a visual manager theme?

Scheduled Pinned Locked Moved C / C++ / MFC
sharepointgraphicsquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Maximilien
    wrote on last edited by
    #1

    (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!

    A L 2 Replies Last reply
    0
    • M Maximilien

      (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!

      A Offline
      A Offline
      Albert Holguin
      wrote on last edited by
      #2

      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.

      M 1 Reply Last reply
      0
      • M Maximilien

        (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!

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Have you looked at https://msdn.microsoft.com/en-us/library/bb983031.aspx[^]?

        M 1 Reply Last reply
        0
        • L Lost User

          Have you looked at https://msdn.microsoft.com/en-us/library/bb983031.aspx[^]?

          M Offline
          M Offline
          Maximilien
          wrote on last edited by
          #4

          Thanks, That was just too easy... :~

          I'd rather be phishing!

          L 1 Reply Last reply
          0
          • A Albert Holguin

            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.

            M Offline
            M Offline
            Maximilien
            wrote on last edited by
            #5

            Thanks, That was just too easy... :~

            I'd rather be phishing!

            1 Reply Last reply
            0
            • M Maximilien

              Thanks, That was just too easy... :~

              I'd rather be phishing!

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              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.

              M 1 Reply Last reply
              0
              • L Lost User

                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.

                M Offline
                M Offline
                Maximilien
                wrote on last edited by
                #7

                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!

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups