VB-Tec.de Visual Basic - Technik, FAQ, Tricks, BeispieleHome / System / Multimedia / SysColor Systemfarbe in RGB konvertieren |
| Historie | |
| 11.01.2001 | Nach Anregung von Harald M. Genauck (AboutVB): Alternative OLE-Version |
| 04.01.2001 | Erste Version |
x = SysColor(vbButtonFace) MsgBox "&H" & Hex$(x)die Farbe der Button-Oberfläche zurück (normalerweise hellgrau, also &HC0C0C0). Zur Umsetzung eines RGB-Wertes in seine einzelnen Farbanteile: siehe hier.
Private Declare Function GetSysColor Lib "user32" ( _
ByVal nIndex As Long _
) As Long
Die eigentliche Funktion arbeitet folgendermaßen:
Public Function SysColor(ByVal Color As Long) As Long
If Color And &H80000000 Then
'Systemfarbe:
SysColor = GetSysColor(Color And &H7FFFFFFF)
Else
'konventioneller RGB-Wert:
SysColor = Color
End If
End Function
Declare Function OleTranslateColor Lib "oleaut32.dll" ( _
ByVal lOleColor As Long, ByVal lHPalette As Long, _
ByRef lColorRef As Long
) As Long
Public Function OleSysColor(ByVal Color As Long) As Long
OleTranslateColor Color, 0&, OleSysColor
End Function
© Jost Schwider, 04.01.2001-11.01.2001 - http://vb-tec.de/syscolor.htm