
04/12/2004, 00:49
|
 | | | Fecha de Ingreso: diciembre-2001 Ubicación: Monterrey, Nuevo León
Mensajes: 433
Antigüedad: 23 años, 4 meses Puntos: 7 | |
FedericoC:
Te dejo este ejemplo:
Código:
Option Explicit
'*******************************
'Documentación Platform SDK
'STDAPI OleTranslateColor (
' OLE_COLOR clr, //Color to be converted into a COLORREF
' HPALETTE hpal, //Palette used for conversion
' COLORREF *pcolorref //Pointer to the caller's variable that
' // receives the converted result
');
Private Declare Function OleTranslateColor Lib "olepro32.dll" ( _
ByVal clr As Long, _
ByVal hpal As Long, _
ByRef pcolorref As Long) As Long
'*******************************
Private Type LongWrapper
lColor As Long
End Type
Private Type HTMLColorFormat
bA As Byte
bB As Byte
bC As Byte
bD As Byte
End Type
Private Sub Form_Load()
'Colores de sistema
Debug.Print TranslateToHTMLColor(vbDesktop) 'Color del escritorio
Debug.Print TranslateToHTMLColor(vbInactiveTitleBar) 'Color de barras de título inactivas
Debug.Print TranslateToHTMLColor(vbHighlight) 'Color del resalte de menús
Debug.Print TranslateToHTMLColor(vbButtonFace) 'Color de los formularios
Debug.Print TranslateToHTMLColor(vbInfoBackground) 'Color de los tooltips
'Constantes de color
Debug.Print TranslateToHTMLColor(vbRed)
Debug.Print TranslateToHTMLColor(vbGreen)
Debug.Print TranslateToHTMLColor(vbBlue)
Debug.Print TranslateToHTMLColor(vbYellow)
'Colores definidos por usuario
Debug.Print TranslateToHTMLColor(&H80&)
Debug.Print TranslateToHTMLColor(&HFF8080)
End Sub
Private Function TranslateToHTMLColor(ByVal ocVBColor As OLE_COLOR) As String
Dim lwTmpVBColor As LongWrapper
Dim hcfColorFormat As HTMLColorFormat
'Esto es por si pasamos alguna constante de color de VB
OleTranslateColor ocVBColor, 0&, lwTmpVBColor.lColor
'Copiamos una estructura en la otra
LSet hcfColorFormat = lwTmpVBColor
'Reacomodamos las posiciones
TranslateToHTMLColor = "#" & _
Right$("0" & Hex$(hcfColorFormat.bA), 2&) & _
Right$("0" & Hex$(hcfColorFormat.bB), 2&) & _
Right$("0" & Hex$(hcfColorFormat.bC), 2&)
End Function
El resultado de las llamadas te lo pondrá en la ventana de resultados inmediatos de VB.
Saludos.
Última edición por Beakdan; 04/12/2004 a las 13:45 |