CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 4 of 4

Thread: OLE_COLOR confusion

  1. #1
    Join Date
    Jan 2005

    OLE_COLOR confusion


    Can anyone please explain the format of OLE_COLOR to me?

    I have the following code:
    dim c as OLE_COLOR
    c = &h0000ff00 ' this is what i actually type when using setting c to be green
    The '&h0000ff00' becomes '&HFF00' when I move to the next line of code.

    Why does it get truncated?

    Also, why is the '&H' needed?

    Thanks very much,

    Last edited by dhartigan; September 20th, 2005 at 08:10 AM.

  2. #2
    Join Date
    Jul 2001
    Sunny South Africa

    Re: OLE_COLOR confusion

    The OLE_COLOR data type is used for properties that return colors. When a property is declared as OLE_COLOR, the Properties window will display a color-picker dialog that allows the user to select the color for the property visually, rather than having to remember the numeric equivalent.

    OLE_COLOR is treated internally as a Long.

    Color Constants

    vbBlack &h00 Black
    vbRed &hFF Red
    vbGreen &hFF00 Green
    vbYellow &hFFFF Yellow
    vbBlue &hFF0000 Blue
    vbMagenta &hFF00FF Magenta
    vbCyan &hFFFF00 Cyan
    vbWhite &hFFFFFF White

    Hopefully this helps!
    All my Articles

  3. #3
    Join Date
    Dec 2001

    Re: OLE_COLOR confusion

    Color values are stored in 4 bytes, so it's really a Long. The "&H" is how vb denotes Hex codes, which is easier to read but not actually necessary in this case. You can get the Long value by just checking the value of the variable.

    The Hex value doesn't always need the zeros, so it will format the number appropriately.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  4. #4
    Join Date
    Jan 2005

    Re: OLE_COLOR confusion

    Thanks very much for the quick responses HannesTheGreat and Wizbang. It's a bit clearer to me now.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)