Loading ...
Sorry, an error occurred while loading the content.

GetThemeColor and TMT_GRADIENTCOLOR1

Expand Messages
  • codewiz1951
    I am trying to use theme colors in XP to draw a gradient background that is not rectangular. I am utilizing atltheme.h to call GetThemeColor(BP_PUSHBUTTON,
    Message 1 of 9 , Apr 23 10:44 AM
    View Source
    • 0 Attachment
      I am trying to use theme colors in XP to draw a gradient background
      that is not rectangular. I am utilizing atltheme.h to call
      GetThemeColor(BP_PUSHBUTTON, PBS_HOT, TMT_GRADIENTCOLOR1, &c). I am
      trying to retrieve just one gradient color at the moment. I've tried
      using DrawThemeBackground for a button. The colors are correct, but
      the shape cannot be changed to fit the region I am filling.

      I've discovered that most theme parts do not return gradient colors.
      (I am able to get some colors, just not the gradient colors.) Does
      anyone know how to retrieve the gradient colors used to draw themed
      buttons? Most of the examples I have found hard code the gradient
      colors to look like the theme colors.

      Thanks In Advance,
      code
    • Jim Barry
      ... Themed buttons are actually drawn using a template bitmap, so there are no gradient colours to retrieve. -- Jim Barry, Microsoft MVP
      Message 2 of 9 , Apr 24 2:17 AM
      View Source
      • 0 Attachment
        codewiz1951 wrote:
        > I've discovered that most theme parts do not return gradient colors.
        > (I am able to get some colors, just not the gradient colors.) Does
        > anyone know how to retrieve the gradient colors used to draw themed
        > buttons?

        Themed buttons are actually drawn using a template bitmap, so there are no gradient colours to retrieve.

        --
        Jim Barry, Microsoft MVP
      • codewiz1951
        Thanks very much. I looked in C: WINDOWS Resources Themes Luna Shell Metallic shellstyle.dll, but I could not find a template that had the same colors as a
        Message 3 of 9 , Apr 24 5:44 AM
        View Source
        • 0 Attachment
          Thanks very much.

          I looked in
          C:\WINDOWS\Resources\Themes\Luna\Shell\Metallic\shellstyle.dll, but I
          could not find a template that had the same colors as a push button.
          Is this template stored in an accessible location?

          code

          --- In wtl@yahoogroups.com, "Jim Barry" <j.barry@...> wrote:
          >
          > codewiz1951 wrote:
          > > I've discovered that most theme parts do not return gradient colors.
          > > (I am able to get some colors, just not the gradient colors.) Does
          > > anyone know how to retrieve the gradient colors used to draw themed
          > > buttons?
          >
          > Themed buttons are actually drawn using a template bitmap, so there
          are no gradient colours to retrieve.
          >
          > --
          > Jim Barry, Microsoft MVP
          >
        • Jim Barry
          ... Yes, have a look at C: WINDOWS Resources Themes Luna luna.msstyles in the resource editor. For the Silver colour scheme, the bitmap resource is named
          Message 4 of 9 , Apr 24 6:19 AM
          View Source
          • 0 Attachment
            codewiz1951 wrote:
            > I looked in
            > C:\WINDOWS\Resources\Themes\Luna\Shell\Metallic\shellstyle.dll, but I
            > could not find a template that had the same colors as a push button.
            > Is this template stored in an accessible location?

            Yes, have a look at C:\WINDOWS\Resources\Themes\Luna\luna.msstyles in the resource editor. For the "Silver" colour scheme, the bitmap resource is named "METALLIC_BUTTON_BMP".

            --
            Jim Barry, Microsoft MVP
          • codewiz1951
            Thanks so much. I ve never dealt in themes before except to turn them on in my projects. It never even occurred to me to open an .msstyles file type as a
            Message 5 of 9 , Apr 24 6:39 AM
            View Source
            • 0 Attachment
              Thanks so much.

              I've never dealt in themes before except to turn them on in my
              projects. It never even occurred to me to open an .msstyles file type
              as a resource. That was a real eye opener this morning. I feel so
              ignorant. :-)

              I am guessing this stuff is undocumented? I did a search of
              METALLIC_BUTTON_BMP on google and came up empty.

              code
              --- In wtl@yahoogroups.com, "Jim Barry" <j.barry@...> wrote:
              >
              > codewiz1951 wrote:
              > > I looked in
              > > C:\WINDOWS\Resources\Themes\Luna\Shell\Metallic\shellstyle.dll, but I
              > > could not find a template that had the same colors as a push button.
              > > Is this template stored in an accessible location?
              >
              > Yes, have a look at C:\WINDOWS\Resources\Themes\Luna\luna.msstyles
              in the resource editor. For the "Silver" colour scheme, the bitmap
              resource is named "METALLIC_BUTTON_BMP".
              >
              > --
              > Jim Barry, Microsoft MVP
              >
            • Jim Barry
              ... Oh yes, totally undocumented. -- Jim Barry, Microsoft MVP
              Message 6 of 9 , Apr 24 7:15 AM
              View Source
              • 0 Attachment
                codewiz1951 wrote:
                > I am guessing this stuff is undocumented? I did a search of
                > METALLIC_BUTTON_BMP on google and came up empty.

                Oh yes, totally undocumented.

                --
                Jim Barry, Microsoft MVP
              • codewiz1951
                That certainly explains why every article I ve found for custom theme shapes hard coded the colors and blend factors for the three known themes. I thought I
                Message 7 of 9 , Apr 24 7:51 AM
                View Source
                • 0 Attachment
                  That certainly explains why every article I've found for custom theme
                  shapes hard coded the colors and blend factors for the three "known"
                  themes.

                  I thought I could load the bitmaps and call GetPixel to retrieve the
                  "real" colors. But I would have to know the button name symbols for
                  non-MS themes as well.

                  code

                  --- In wtl@yahoogroups.com, "Jim Barry" <j.barry@...> wrote:
                  >
                  > codewiz1951 wrote:
                  > > I am guessing this stuff is undocumented? I did a search of
                  > > METALLIC_BUTTON_BMP on google and came up empty.
                  >
                  > Oh yes, totally undocumented.
                  >
                  > --
                  > Jim Barry, Microsoft MVP
                  >
                • Jim Barry
                  ... You could draw the theme background into a memory DC and examine the resulting image. However, I m not sure it s such a great idea. What if your code is
                  Message 8 of 9 , Apr 24 8:29 AM
                  View Source
                  • 0 Attachment
                    codewiz1951 wrote:
                    > I thought I could load the bitmaps and call GetPixel to retrieve the
                    > "real" colors. But I would have to know the button name symbols for
                    > non-MS themes as well.

                    You could draw the theme background into a memory DC and examine the resulting image. However, I'm not sure it's such a great idea. What if your code is running with a visual style that happens not to use a simple vertical gradient for its buttons?

                    --
                    Jim Barry, Microsoft MVP
                  • codewiz1951
                    Thanks. I ran through a full gamut of scenarios. None of them are attractive. All of this started because I wanted to do a managed c++ button control on
                    Message 9 of 9 , Apr 24 8:50 AM
                    View Source
                    • 0 Attachment
                      Thanks. I ran through a full gamut of scenarios. None of them are
                      attractive. All of this started because I wanted to do a managed c++
                      button control on codeproject. I wanted a button with variable radius
                      corners and the ability to have some round and square corners.
                      Everything was fine until I had the foolish idea of theming the button.

                      I was not able to get the theming to work right in managed code, so I
                      moved back to WTL and native code to get it working. (That is my
                      comfort zone.) Thanks to your answers, I'll hard code to the colors
                      in the three known color schemes and call it a feature rather than a
                      limitation. (Or I will add a configuration file with the known theme
                      colors for buttons and let other developers add their own variations.)
                      :-)

                      All of this does make me wonder how the WINE folks are handling this
                      under Linux. I started examining some of their code, but there aren't
                      enough hours in my day.

                      code

                      --- In wtl@yahoogroups.com, "Jim Barry" <j.barry@...> wrote:
                      >
                      > codewiz1951 wrote:
                      > > I thought I could load the bitmaps and call GetPixel to retrieve the
                      > > "real" colors. But I would have to know the button name symbols for
                      > > non-MS themes as well.
                      >
                      > You could draw the theme background into a memory DC and examine the
                      resulting image. However, I'm not sure it's such a great idea. What if
                      your code is running with a visual style that happens not to use a
                      simple vertical gradient for its buttons?
                      >
                      > --
                      > Jim Barry, Microsoft MVP
                      >
                    Your message has been successfully submitted and would be delivered to recipients shortly.