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. CBitmapButton

CBitmapButton

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsregexhelpquestionlearning
4 Posts 2 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
    Marissa182
    wrote on last edited by
    #1

    I have some bitmap buttons i edited thier images in the resource editor and im using the CBitmapButton::AutoLoad() member my problem is that the grey color the editor has doesnt match the grey color or buttons or windows is there a way to give it that windows grey look or does anyone know the exact rgb value of the windows default grey color?

    T 1 Reply Last reply
    0
    • M Marissa182

      I have some bitmap buttons i edited thier images in the resource editor and im using the CBitmapButton::AutoLoad() member my problem is that the grey color the editor has doesnt match the grey color or buttons or windows is there a way to give it that windows grey look or does anyone know the exact rgb value of the windows default grey color?

      T Offline
      T Offline
      Toni78
      wrote on last edited by
      #2

      I don't know the exact grey color of buttons but I can tell you this much. What you are looking for might not be the best solution. In Windows, the default colors can be changed thus making your buttons look awkward. You have no way of knowing before hand what the background color would be. If you implement a bitmap button and set its background color to the dialog box color, it might work on your system, but it might not work on other systems. To draw a bitmap button with transparent background you need to use a mask when painting the bitmap. So you need to have two bitmaps, one that stores the normal image and the other one that has the mask. A mask is nothing but an image that corresponds to the original but the background is white and the foreground is black. You need to perform the following operations: 1. Output the normal bitmap by XOR-ing it with the target device 2. Output the mask bitmap by AND-ing it with the target device at the exact location of the original bitmap. 3. Output the normal bitmap by XOR-ing it with the target device. At the end you will have a transparent button. // Afterall, I realized that even my comment lines have bugs When one cannot invent, one must at least improve (in bed).-My latest fortune cookie

      M 1 Reply Last reply
      0
      • T Toni78

        I don't know the exact grey color of buttons but I can tell you this much. What you are looking for might not be the best solution. In Windows, the default colors can be changed thus making your buttons look awkward. You have no way of knowing before hand what the background color would be. If you implement a bitmap button and set its background color to the dialog box color, it might work on your system, but it might not work on other systems. To draw a bitmap button with transparent background you need to use a mask when painting the bitmap. So you need to have two bitmaps, one that stores the normal image and the other one that has the mask. A mask is nothing but an image that corresponds to the original but the background is white and the foreground is black. You need to perform the following operations: 1. Output the normal bitmap by XOR-ing it with the target device 2. Output the mask bitmap by AND-ing it with the target device at the exact location of the original bitmap. 3. Output the normal bitmap by XOR-ing it with the target device. At the end you will have a transparent button. // Afterall, I realized that even my comment lines have bugs When one cannot invent, one must at least improve (in bed).-My latest fortune cookie

        M Offline
        M Offline
        Marissa182
        wrote on last edited by
        #3

        Can you give a code example?

        T 1 Reply Last reply
        0
        • M Marissa182

          Can you give a code example?

          T Offline
          T Offline
          Toni78
          wrote on last edited by
          #4

          I am sorry but I am away from my normal workstation, so I at this moment don't have access to my code. What I described is kind of involving, and it doesn't consists of just a few lines of code, so I cannot reproduce it right now. You need to create a CBitmapButton derived class, and then override DrawItem if I remember it correctly. Then you need to use BitBlt to perform bitwise operations. However, to avoid flicker you should not write directly to the target device. You should create a bitmap in the memory and perform the operations there. Sorry that I cannot help you with source code.:( // Afterall, I realized that even my comment lines have bugs When one cannot invent, one must at least improve (in bed).-My latest fortune cookie

          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