Private Declare Function TranslateColor Lib "olepro32.dll" _
Alias "OleTranslateColor" (ByVal clr As OLE_COLOR, _
ByVal palet As Long, col As Long) As Long
Private Function GetRealColor(ByVal Color As OLE_COLOR) As Long
Dim R As Long
R = TranslateColor(Color, 0, GetRealColor)
If R <> 0 Then 'raise an error
End If
End Function
Tuesday, December 16, 2008
[vb6] Convert system colors
Color values are specified in Visual Basic using the OLE_COLOR type. The colors come in two flavors; either true RGB values or the system colors with values above &H80000000. When using Visual Basic functions that take color parameters, VB will convert the system colors to their real value for you. However, Windows API functions don't understand the system values, so you will have to convert them manually. One way to do this is to use the OleTranslateColor function. If you convert a real color, i.e. below &H80000000, the function simply returns the same value, but for system colors, it will return a value that can be used as color parameter in an API call.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment