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

colorref

Scheduled Pinned Locked Moved C / C++ / MFC
com
10 Posts 4 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.
  • D Offline
    D Offline
    Dody_DK
    wrote on last edited by
    #1

    upon the following tutorials http://codeproject.com/miscctrl/#Colour+Selection+Controls[^] and especially http://codeproject.com/miscctrl/colour_picker.asp[^] and http://codeproject.com/miscctrl/colourpickerxp.asp[^] I could successfully use te classes, but I want to ask, upon these two articles, is the any way to get the value of the COLORREF and disploay it in a MessageBox or in an editbox using SetWindowText() thanks in advance...

    C 1 Reply Last reply
    0
    • D Dody_DK

      upon the following tutorials http://codeproject.com/miscctrl/#Colour+Selection+Controls[^] and especially http://codeproject.com/miscctrl/colour_picker.asp[^] and http://codeproject.com/miscctrl/colourpickerxp.asp[^] I could successfully use te classes, but I want to ask, upon these two articles, is the any way to get the value of the COLORREF and disploay it in a MessageBox or in an editbox using SetWindowText() thanks in advance...

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      From MSDN:

      When specifying an explicit RGB color, the COLORREF value has the following hexadecimal form:

      0x00bbggrr

      The low-order byte contains a value for the relative intensity of red; the second byte contains a value for green;
      and the third byte contains a value for blue. The high-order byte must be zero. The maximum value for a single byte is 0xFF.

      So just use masks to retrieve the colors: COLORREF Color = ....; int BlueValue = Color&0x00FF0000; int GreenValue = Color&0x0000FF00; int RedValue = Color&0x000000FF;

      M 1 Reply Last reply
      0
      • C Cedric Moonen

        From MSDN:

        When specifying an explicit RGB color, the COLORREF value has the following hexadecimal form:

        0x00bbggrr

        The low-order byte contains a value for the relative intensity of red; the second byte contains a value for green;
        and the third byte contains a value for blue. The high-order byte must be zero. The maximum value for a single byte is 0xFF.

        So just use masks to retrieve the colors: COLORREF Color = ....; int BlueValue = Color&0x00FF0000; int GreenValue = Color&0x0000FF00; int RedValue = Color&0x000000FF;

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

        or use the GetRValue, GetGValue, GetBValuefunctions.


        Maximilien Lincourt Your Head A Splode - Strong Bad

        C D 2 Replies Last reply
        0
        • M Maximilien

          or use the GetRValue, GetGValue, GetBValuefunctions.


          Maximilien Lincourt Your Head A Splode - Strong Bad

          C Offline
          C Offline
          Cedric Moonen
          wrote on last edited by
          #4

          True, because I just realized my version was completely bugged :~ . It works well for the red component but for this other ones, the bits needs to be shifted...

          T 1 Reply Last reply
          0
          • M Maximilien

            or use the GetRValue, GetGValue, GetBValuefunctions.


            Maximilien Lincourt Your Head A Splode - Strong Bad

            D Offline
            D Offline
            Dody_DK
            wrote on last edited by
            #5

            oki, but how can I use the GetRValue, GetGValue, GetBValue functions to display the colorref value in a messagebox or an editbox? an example code? thanks alot

            C 1 Reply Last reply
            0
            • D Dody_DK

              oki, but how can I use the GetRValue, GetGValue, GetBValue functions to display the colorref value in a messagebox or an editbox? an example code? thanks alot

              C Offline
              C Offline
              Cedric Moonen
              wrote on last edited by
              #6

              Just use printf: char szText[255]; printf(szText,"Red value: %i, Blue value: %i, Green value: %i",GetRValue(...),GetBValue(...),GetGValue(...)); Of course, you have to replace the ... by your COLORREF variable ;)

              D 1 Reply Last reply
              0
              • C Cedric Moonen

                True, because I just realized my version was completely bugged :~ . It works well for the red component but for this other ones, the bits needs to be shifted...

                T Offline
                T Offline
                toxcct
                wrote on last edited by
                #7

                Cedric Moonen wrote:

                True, because I just realized my version was completely bugged

                yeah, you forgot the shifts...

                int BlueValue = Color&0x00FF0000 >> 16;
                int GreenValue = Color&0x0000FF00 >> 8;
                int RedValue = Color&0x000000FF;

                ;)


                TOXCCT >>> GEII power
                [toxcct][VisualCalc 2.20]

                1 Reply Last reply
                0
                • C Cedric Moonen

                  Just use printf: char szText[255]; printf(szText,"Red value: %i, Blue value: %i, Green value: %i",GetRValue(...),GetBValue(...),GetGValue(...)); Of course, you have to replace the ... by your COLORREF variable ;)

                  D Offline
                  D Offline
                  Dody_DK
                  wrote on last edited by
                  #8

                  yes I got it, but how can I use it with the following classes http://codeproject.com/miscctrl/colour_picker.asp[^] and http://codeproject.com/miscctrl/colourpickerxp.asp[^] I mean, I want the color value of the chosen color from the drop button. thanks alot

                  C 1 Reply Last reply
                  0
                  • D Dody_DK

                    yes I got it, but how can I use it with the following classes http://codeproject.com/miscctrl/colour_picker.asp[^] and http://codeproject.com/miscctrl/colourpickerxp.asp[^] I mean, I want the color value of the chosen color from the drop button. thanks alot

                    C Offline
                    C Offline
                    Cedric Moonen
                    wrote on last edited by
                    #9

                    For the first one, just use COLORREF GetColour(); from the control. Dude, when you use classes from an article here, first read how to use it (and there is also example source code with the article). If we don't use this control, we don't know how to use. It just took me 30 seconds looking at the text of the article to find how to use it.

                    D 1 Reply Last reply
                    0
                    • C Cedric Moonen

                      For the first one, just use COLORREF GetColour(); from the control. Dude, when you use classes from an article here, first read how to use it (and there is also example source code with the article). If we don't use this control, we don't know how to use. It just took me 30 seconds looking at the text of the article to find how to use it.

                      D Offline
                      D Offline
                      Dody_DK
                      wrote on last edited by
                      #10

                      don't call me a dude, and I read before I ask, and if it is bothering you then don't answer at all, I don't need your answer, got it dude?

                      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