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. Changing COLORREF to RGB

Changing COLORREF to RGB

Scheduled Pinned Locked Moved C / C++ / MFC
3 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.
  • H Offline
    H Offline
    harinat
    wrote on last edited by
    #1

    Hello Guys... Thank you guys for the reply... i have one more doubt...i wanna change the COLORREF item to RGB structure..ie i want the seperate values for R, G and B Thanks in Advance, Hariharan.S.N

    S B 2 Replies Last reply
    0
    • H harinat

      Hello Guys... Thank you guys for the reply... i have one more doubt...i wanna change the COLORREF item to RGB structure..ie i want the seperate values for R, G and B Thanks in Advance, Hariharan.S.N

      S Offline
      S Offline
      Steve S
      wrote on last edited by
      #2

      GetRValue and friends... Steve S

      1 Reply Last reply
      0
      • H harinat

        Hello Guys... Thank you guys for the reply... i have one more doubt...i wanna change the COLORREF item to RGB structure..ie i want the seperate values for R, G and B Thanks in Advance, Hariharan.S.N

        B Offline
        B Offline
        BaldwinMartin
        wrote on last edited by
        #3

        COLORREF RGB( BYTE bRed, // red component of color BYTE bGreen, // green component of color BYTE bBlue // blue component of color ); above is the structure #define RGB(r, g ,b) ((DWORD) (((BYTE) (r) | \ ((WORD) (g) << 8)) | \ (((DWORD) (BYTE) (b)) << 16))) Above is the Macro So COLORREF is a 24-bit RGB color. BYTE GetBValue( WORD rgb // 32-bit RGB value // blue ); BYTE GetGValue( DWORD rgb // 32-bit RGB value // green ); BYTE GetRValue( DWORD rgb // 32-bit RGB value // red ); The GetRValue macro is defined as follows: #define GetRValue(rgb) ((BYTE) (rgb)) #define GetGValue(rgb) ((BYTE) (rgb)) #define GetBValue(rgb) ((BYTE) (rgb)) long green = 128; long red = 128; long blue = 128; COLORREF clr = RGB((blue + (green * 256) + (red * 255)); You may also create a structure of you own with COLORREF as a element with it. Hope this helps. Best Wishes and Happy Holiday's, ez_way

        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