r = color And &HFF&
g = (color And &HFF00&) \ &H100&
b = (color And &HFF0000) \ &H10000
b = (color And &HFF0000) \ &H10000
There are some system colors that have funny values like &H8000000F&. Unfortunately they don't work this way. You can use the GetSysColor API function to find these color values. Use And to mask off the leftmost digit. Then use GetSysColor to see get the color value.
Public Declare Function GetSysColor Lib "user32" Alias "GetSysColor" _
(ByVal nIndex As Long) As Long
Public Declare Function GetSysColor Lib "user32" Alias "GetSysColor" _
(ByVal nIndex As Long) As Long
If color And &H80000000 Then color = GetSysColor(color And &HFFFFFF)
One final case occurs if you use Point to get the color of a pixel that does not exist. For example, on a form with ScaleMode = vbPixels, Point(-100, -100) returns -1 because
No comments :
Post a Comment