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

Thread: OLE_COLOR confusion

  1. #1
    Join Date
    Jan 2005
    Posts
    77

    OLE_COLOR confusion

    Hi,

    Can anyone please explain the format of OLE_COLOR to me?

    I have the following code:
    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,

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

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,267

    Re: OLE_COLOR confusion

    MSDN
    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!
    [SIGPIC][/SIGPIC]
    All my Articles
    Hannes

  3. #3
    Join Date
    Dec 2001
    Posts
    6,332

    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
    Posts
    77

    Re: OLE_COLOR confusion

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

    dhartigan

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)