Private Sub pConvertToRGB(ByRef color As Long, R As Long, G As Long, B As Long) Dim strColor As String strColor = Right$("000000" & Hex$(color), 6) R = Val("&h" & Right$(strColor, 2)) G = Val("&h" & Mid$(strColor, 3, 2)) B = Val("&h" & Left$(strColor, 2)) End Sub Dim R As Long Dim G As Long Dim B As Long Dim Color as Long Color=RGB(12,23,45) pConvertToRGB Color, R, G, B MsgBox(R) Msgbox(g) msgbox(b)
谢谢kingcom_xu 对于系统颜色的问题我自己已经找到答案: Declare Function GetSysColor Lib "user32" Alias "GetSysColor" (ByVal nIndex As Long) As Long
例如输入:msgbox &H8000000F
( &H8000000F是代表按钮表面颜色的系统颜色常数)
无论现在的系统配色怎样,得到的永远是-2147483633。
我希望当系统配色方案指定按钮表面颜色是什么(如红),就通过&H8000000F
得到什么(如红)。
Dim strColor As String
strColor = Right$("000000" & Hex$(color), 6)
R = Val("&h" & Right$(strColor, 2))
G = Val("&h" & Mid$(strColor, 3, 2))
B = Val("&h" & Left$(strColor, 2))
End Sub
Dim R As Long
Dim G As Long
Dim B As Long
Dim Color as Long
Color=RGB(12,23,45)
pConvertToRGB Color, R, G, B
MsgBox(R)
Msgbox(g)
msgbox(b)
对于系统颜色的问题我自己已经找到答案:
Declare Function GetSysColor Lib "user32" Alias "GetSysColor" (ByVal nIndex As Long) As Long