Código vb:
Ver original
Option Explicit Private Const COLOR_BTNFACE = 15 'Button Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long Private Declare Function GetSysColorBrush Lib "user32" (ByVal nIndex As Long) As Long Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _ ByVal hWnd1 As Long, ByVal hWnd2 As Long, _ ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" ( _ ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function InvalidateRect Lib "user32" _ (ByVal hwnd As Long, lpRect As Long, ByVal bErase As Long) As Long Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long Private Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long Private Enum enuTBType enuTB_FLAT = 1 enuTB_STANDARD = 2 End Enum Private Const GCL_HBRBACKGROUND = (-10) Public Sub setToolbarBackgroundColor(tlbBar As MSComctlLib.Toolbar, color As Long, Optional restore As Boolean = False) Dim LngNew As Long If (restore) Then LngNew = GetSysColorBrush(COLOR_BTNFACE) Else LngNew = CreateSolidBrush(color) '(RGB(157, 185, 167)) End If 'LngNew = CreatePatternBrush(Picture1.Picture.Handle) 'Creates the background from a Picture Handle If (tlbBar.Style = tbrFlat) Then ChangeTBBack tlbBar, LngNew, enuTB_FLAT Else 'Change Backcolor to STANDARD TB (Toolbar2) ChangeTBBack tlbBar, LngNew, enuTB_STANDARD End If 'Refresh Screen to see changes InvalidateRect 0&, 0&, False End Sub Private Sub ChangeTBBack(TB As Object, PNewBack As Long, pType As enuTBType) Dim lTBWnd As Long Select Case pType Case enuTB_FLAT 'FLAT Button Style Toolbar DeleteObject SetClassLong(TB.hwnd, GCL_HBRBACKGROUND, PNewBack) 'Its Flat, Apply directly to TB Hwnd Case enuTB_STANDARD 'STANDARD Button Style Toolbar lTBWnd = FindWindowEx(TB.hwnd, 0, "msvb_lib_toolbar", vbNullString) 'Standard, find Hwnd first DeleteObject SetClassLong(lTBWnd, GCL_HBRBACKGROUND, PNewBack) 'Set new Back End Select End Sub '// Con este procedimiento pones las ToolBar con el Color Original el Grisaceo '// Pasas como parametro un color, pero no lo toma en cuenta. '// Pasas como parametro un Toolbar (Ej Me.tblGuardar) pero ignora el Toolbar y se los cambia a todos los de la aplicaicon. Call setToolbarBackgroundColor(Me.tblGuardar, vbRed, True) '// En cambio si pones el tercer parameto como false, el color cambiara Call setToolbarBackgroundColor(Me.tblGuardar, vbWhite, False)
Recuerden que cambia todos los toolbar, alquien sabe como cambiar el oclor solo a un Toolbar...