Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Integer, _ ByVal lParam As Any _ ) 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 Const WM_USER = &H400 Private Const TB_SETSTYLE = WM_USER + 56 Private Const TB_GETSTYLE = WM_USER + 57 Private Const TBSTYLE_FLAT = &H800 Private Const TBSTYLE_LIST = &H1000Public Sub ToolbarStyle(tlb As Toolbar, _ tlbToolbarStyle As Long) Dim lngStyle As Long Dim lngResult As Long Dim lngHWND As Long ' Find child window and get style bits lngHWND = FindWindowEx(tlb.hwnd, 0&, "ToolbarWindow32", vbNullString) lngStyle = SendMessage(lngHWND, TB_GETSTYLE, 0&, 0&) ' Use a case statement to get the effect Select Case tlbToolbarStyle Case 1: ' Creates an Office 97 like toolbar lngStyle = lngStyle Or TBSTYLE_FLAT Case 2: ' Creates an Explorer 4.0 like toolbar, ' with text to the right ' of the picture. You must provide text ' in order to get the effect. lngStyle = lngStyle Or TBSTYLE_FLAT Or TBSTYLE_LIST Case Else lngStyle = lngStyle Or TBSTYLE_FLAT End Select ' Use the API call to change the toolbar lngResult = SendMessage(lngHWND, TB_SETSTYLE, 0, lngStyle) ' Show the effects tlb.Refresh End Sub Private Sub Command1_Click() Me.Toolbar1.ButtonWidth = 1000 Call ToolbarStyle(Me.Toolbar1, 2) End Sub
要不然我还来网上找高手呀
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Integer, _
ByVal lParam As Any _
) 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 Const WM_USER = &H400
Private Const TB_SETSTYLE = WM_USER + 56
Private Const TB_GETSTYLE = WM_USER + 57
Private Const TBSTYLE_FLAT = &H800
Private Const TBSTYLE_LIST = &H1000Public Sub ToolbarStyle(tlb As Toolbar, _
tlbToolbarStyle As Long)
Dim lngStyle As Long
Dim lngResult As Long
Dim lngHWND As Long ' Find child window and get style bits
lngHWND = FindWindowEx(tlb.hwnd, 0&, "ToolbarWindow32", vbNullString)
lngStyle = SendMessage(lngHWND, TB_GETSTYLE, 0&, 0&) ' Use a case statement to get the effect
Select Case tlbToolbarStyle
Case 1:
' Creates an Office 97 like toolbar
lngStyle = lngStyle Or TBSTYLE_FLAT
Case 2:
' Creates an Explorer 4.0 like toolbar,
' with text to the right
' of the picture. You must provide text
' in order to get the effect.
lngStyle = lngStyle Or TBSTYLE_FLAT Or TBSTYLE_LIST
Case Else
lngStyle = lngStyle Or TBSTYLE_FLAT
End Select ' Use the API call to change the toolbar
lngResult = SendMessage(lngHWND, TB_SETSTYLE, 0, lngStyle) ' Show the effects
tlb.Refresh
End Sub
Private Sub Command1_Click()
Me.Toolbar1.ButtonWidth = 1000
Call ToolbarStyle(Me.Toolbar1, 2)
End Sub