Visual Basic Foro
Programación => Visual Basic 6 => Mensaje iniciado por: xkiz ™ en Octubre 01, 2009, 04:39:55 pm
-
bue como dice el titulo, alguien sabe como cambiarle el background color a los toolbar, osea estoy usando este API-ucToolbar 3.1 (http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=56769&lngWId=1) que encontre ahi en PSC, pero al ponerle manifest a la aplicacion note que el color de fondo del toolbar no siempre es el mismo que el del formulario, osea si se usa los estilos de XP (Azul, plateado u oliva) si se ve bien , pero si se usa un estilo distinto, como el Zune ya ahi no concuerda el color de fondo, y la verdad es que queda medio feito, visualmente.
estuve buscando en Google codes, pero la verdad no pude hacer funcionar ninguno de estos...
-
uff despues de buscar y buscar puede encontrarlo yo tambien tenia este problema y bueno el principal problema era como estaba delcarado en el ApiViewer TBSTYLE_TRANSPARENT As Long = &H8000 y no se porque carajo hay que poner &H8000& pero bueno se soluciono.
Option Explicit
Private Declare Sub InitCommonControls Lib "comctl32.dll" ()
Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nindex As Long) As Long
Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nindex As Long, ByVal dwnewlong As Long) As Long
Private Declare Function GetWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Const GWL_STYLE As Long = -16
Private Const GW_CHILD As Long = 5
Private Const TBSTYLE_FLAT As Long = &H800
Private Const TBSTYLE_TRANSPARENT As Long = &H8000&
Private Sub Form_Initialize()
InitCommonControls
End Sub
Private Sub Form_Load()
Dim lStyle As Long
Dim hToolbar As Long
hToolbar = GetWindow(Toolbar1.hwnd, GW_CHILD)
lStyle = GetWindowLong(hToolbar, GWL_STYLE)
SetWindowLong hToolbar, GWL_STYLE, lStyle Or TBSTYLE_FLAT Or TBSTYLE_TRANSPARENT
End Sub
Saludos
-
LeandroA - He corregido para classic style del estilo
'Theme =========================================================================
Private Declare Function DrawThemeBackGround Lib "uxtheme.dll" Alias "DrawThemeBackground" (ByVal hTheme As Long, ByVal lhdc As Long, ByVal iPartId As Long, ByVal iStateId As Long, pRect As RECT2, pClipRect As Any) As Long
Private Declare Function OpenThemeData Lib "uxtheme.dll" (ByVal hwnd As Long, ByVal pszClassList As Long) As Long
Private Declare Function CloseThemeData Lib "uxtheme.dll" (ByVal hTheme As Long) As Long
'Private Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As Long
'Private Declare Function OleTranslateColor Lib "oleaut32.dll" (ByVal lOleColor As Long, ByVal lHPalette As Long, lColorRef As Long) As Long
'Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function FillRect Lib "user32.dll" (ByVal hdc As Long, ByRef lpRect As RECT2, ByVal hBrush As Long) As Long
Private mUseThemeReBar As Boolean
Case WM_ERASEBKGND
'-- Flat style bug [?]
'bHandled = True'<<<<
'===============================================================================
GetClientRect UserControl.hwnd, uRct
hTheme = OpenThemeData(0&, StrPtr("ReBar")) '/\/\/\/\/\
If mUseThemeReBar And hTheme Then
If (hTheme) Then
Call DrawThemeBackGround(hTheme, wParam, 6, 0&, uRct, ByVal 0&)
Call CloseThemeData(hTheme)
End If
Else
' hBrush = CreateSolidBrush(TranslateColor(UserControl.BackColor))
'
' If hBrush Then
' FillRect wParam, uRct, hBrush
' DeleteObject hBrush
' End If
bHandled = True '<<<<
End If
'==========