Salve, sono riuscito a cambiare sfondo alla toolbar ed ecco il codice
e li richiamo così:codice:Option Explicit 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 Public Declare Function InvalidateRect Lib "user32" _ (ByVal hwnd As Long, lpRect As Long, ByVal bErase As Long) As Long Public Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long Public Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long Public Enum enuTBType enuTB_FLAT = 1 enuTB_STANDARD = 2 End Enum Private Const GCL_HBRBACKGROUND = (-10) Public 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
Io uso due toolbar una orizzontale in alto ed una verticale a sinistra, ho i seguenti problemi:codice:'sfondo con una immagine LngNew = CreatePatternBrush(pictureAmm.Picture.Handle) 'prende l'immagine da una picturebox ChangeTBBack menuorizzontale, LngNew, enuTB_FLAT 'sfondo con un colore LngNew = CreateSolidBrush(RGB(149, 222, 255)) 'Creates the background from a Color (Long) ChangeTBBack menuverticale, LngNew, enuTB_STANDARD InvalidateRect 0&, 0&, False
1. Se cambio lo sfondo con un immagine sia al menu orizzontale che al verticale mi cambia lo sfondo solo a quella orizzontale ma con l'immagine che volevo inserire a quello verticale.
2. Se voglio inserire un colore come sfondo alla toolbar verticale nn funziona perchè il codice è scritto solo per quella orizzontale, cosa posso cambiare?
Per altri chiarimenti del codice chiedete.

Rispondi quotando