Autor Tema: cambiar backGroundColor en toolbar  (Leído 4143 veces)

0 Usuarios y 1 Visitante están viendo este tema.

xkiz ™

  • Moderador Global
  • Gigabyte
  • *****
  • Mensajes: 283
  • Reputación: +30/-11
    • Ver Perfil
    • xkiz ™
cambiar backGroundColor en toolbar
« 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 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...

LeandroA

  • Administrador
  • Petabyte
  • *****
  • Mensajes: 1128
  • Reputación: +151/-8
    • Ver Perfil
Re:cambiar backGroundColor en toolbar
« Respuesta #1 en: Octubre 02, 2009, 01:11:59 am »
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.

Código: [Seleccionar]
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

igor

  • Bit
  • Mensajes: 9
  • Reputación: +1/-0
    • Ver Perfil
    • incod.ru
Re:cambiar backGroundColor en toolbar
« Respuesta #2 en: Octubre 17, 2011, 07:31:15 pm »
LeandroA    - He corregido para classic style  del estilo

Código: (vb) [Seleccionar]
'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
 '==========
« última modificación: Octubre 17, 2011, 09:48:07 pm por xkiz ™ »
El programa de control de brillo del monitor http://incod.ru/win/mymonic/