Article ID: 175533
Article Last Modified on 6/24/2004
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Const WM_SIZE = &H5
Private Sub Command1_Click()
Dim I As Integer ' Make all Buttons visible
For I = 1 To Toolbar1.Buttons.Count
Toolbar1.Buttons(I).Visible = True
Next I
End Sub
Private Sub Command2_Click()
Dim RetVal As Long
' If Internet Explorer 4.0 is installed, you must repeat the
' following SendMessage line, so that the message is sent twice.
RetVal = SendMessage(Toolbar1.hwnd, WM_SIZE, 0, 0) ' Wrap
' If placing another control on the Toolbar, set it's Left and ZOrder
' properties after the SendMessage. For a demonstration of this,
' see "Example" under "Toolbar Control" in On Line Help.
End Sub
Private Sub Form_Load()
Dim I As Integer
Dim btnX As Button
Me.Width = 4200 ' So that 15 buttons won't fit
Me.Height = 3000 ' So that Command buttons will fit
Toolbar1.Wrappable = True
For I = 1 To 15 ' Add more buttons than will fit
Set btnX = Toolbar1.Buttons.Add(, , , tbrDefault)
If I > 5 Then btnX.Visible = False ' Start with 5 buttons
If I Mod 5 = 0 Then ' Make Groups of 5 (Optional)
Set btnX = Toolbar1.Buttons.Add(, , , tbrSeparator)
End If
Next I
' Place and size Command buttons so that Toolbar1 has room to wrap
With Command1
.Width = 2000
.Caption = "Add Buttons"
.Left = 200
.Top = (Toolbar1.Height * 2) + 250
End With
With Command2
.Width = 2000
.Caption = "Wrap Toolbar"
.Left = 200
.Top = Command1.Top + Command1.Height + 15
End With
End Sub
Additional query words: kbVBp kbdsd kbDSupport kbVBp400bug kbVBp500bug kbVBp600bug kbControl
Keywords: kbbug KB175533