Results 1 to 2 of 2

Thread: converting colors

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    779

    converting colors

    Can someone please tell me what this vb color would be in RGB: &H8000000F&. It is the button face color.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Button Face is a system colour, which means you need to do a lookup into the system colour table. For that you need the GetSysColor API. The last byte of a system colour constant contains the index you need. So for &H8000000F&, it would be Hex F = 15. For Button Text (ForeColor property, typically &H80000012&) it would be Hex 12 (18). Once you have the colou convert it into the RGB components.

    VB Code:
    1. Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
    2.  
    3. Dim lngColour As Long
    4. Dim intRed As Integer
    5. Dim intGreen As Integer
    6. Dim intBlue As Integer
    7.  
    8. lngColour = Form1.BackColor
    9. If lngColour < 0 Then 'Check if it is a system colour
    10.     'get the index into the colour table
    11.     lngColour = lngColour And Not &H80000000
    12.     lngColour = GetSysColor(lngColour)
    13. End If
    14.  
    15. intRed = lngColour And 255
    16. intGreen = lngColour \ 256 And 255
    17. intBlue = lngColour \ 65536 And 255

Posting Permissions

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



Click Here to Expand Forum to Full Width