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. having a color show through another color

having a color show through another color

Scheduled Pinned Locked Moved C / C++ / MFC
cssgraphics
4 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.
  • G Offline
    G Offline
    Gilfrog
    wrote on last edited by
    #1

    I have a grid that you can set a color for each cell. When multiple selection is on and i select cells with a background color in it the selection color over rides the original cell background color. I would like to blend these 2 colors to show that it is selected and show the original cell background color. when drawing i have the 2 COLORREF values. Is there a function to blend these or something along those lines. Similar to how excel handles selection and background colors. thanks

    C C G 3 Replies Last reply
    0
    • G Gilfrog

      I have a grid that you can set a color for each cell. When multiple selection is on and i select cells with a background color in it the selection color over rides the original cell background color. I would like to blend these 2 colors to show that it is selected and show the original cell background color. when drawing i have the 2 COLORREF values. Is there a function to blend these or something along those lines. Similar to how excel handles selection and background colors. thanks

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      If it's just two values, blend them yourself. Or use GDI+, which has transparency, or AlphaBlt ( I think ), which is in Windows 98 upwards. Or go to the WDJ site and download the code for my article on doing alphablending for Windows 95. Christian Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002

      1 Reply Last reply
      0
      • G Gilfrog

        I have a grid that you can set a color for each cell. When multiple selection is on and i select cells with a background color in it the selection color over rides the original cell background color. I would like to blend these 2 colors to show that it is selected and show the original cell background color. when drawing i have the 2 COLORREF values. Is there a function to blend these or something along those lines. Similar to how excel handles selection and background colors. thanks

        C Offline
        C Offline
        Chris Losinger
        wrote on last edited by
        #3

        Rblend = (R1 + R2) / 2 Gblend = (G1 + G2) / 2 Bblend = (B1 + B2) / 2 -c


        Alcohol is the anesthesia by which we endure the operation of life. -- George Bernard Shaw

        Smaller Animals Software

        1 Reply Last reply
        0
        • G Gilfrog

          I have a grid that you can set a color for each cell. When multiple selection is on and i select cells with a background color in it the selection color over rides the original cell background color. I would like to blend these 2 colors to show that it is selected and show the original cell background color. when drawing i have the 2 COLORREF values. Is there a function to blend these or something along those lines. Similar to how excel handles selection and background colors. thanks

          G Offline
          G Offline
          Gilfrog
          wrote on last edited by
          #4

          COLORREF CList::Transform2SelColor(COLORREF clr) { return RGB( abs( ((DWORD)clr&0xFF) - (255 - ((DWORD)m_clrSelection&0xFF)) ), abs( (((DWORD)clr>>8)&0xFF) - (255 -(((DWORD)m_clrSelection>>8)&0xFF)) ), abs( (((DWORD)clr>>16)&0xFF) - (255 - (((DWORD)m_clrSelection>>16)&0xFF)) )); } where clr is the slection color take the absolute value of (R value of the selection color - the inverse of the background color)

          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