Microsoft KB Archive/256857

= BUG: Toolbar with Placeholder Button Does Not Wrap Correctly =

Article ID: 256857

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q256857



SYMPTOMS
When a form contains a Toolbar control with several buttons and several placeholders and the Wrappable property is set to True, when the form is resized to a smaller size, the Toolbar wraps to the next line.

The placeholder buttons on the Toolbar wrap when the edge of the form starts to overlap the first non-placeholder button immediately to the right of the placeholder. However, the buttons to the right of the placeholder wrap incorrectly. They are wrapped onto two lines instead of one and are only partially visible. The Toolbar corrects itself when the first non-placeholder button to the left of the placeholder wraps to the next line.



RESOLUTION
A workaround is to place a dummy placeholder before and after the desired placeholder. However, if several placeholders are side-by-side in a row, this workaround does not resolve the issue because the placeholders act as one unit and wrap together when the form overlaps the left-most placeholder. In this situation, the controls used in conjunction with the placeholders of the Toolbar must be wrapped programmatically.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Open a new Visual Basic Standard EXE project. Form1 is created by default. On the Project menu, click Components. In the Components dialog box, click to select the Microsoft Windows Common Controls 6.0, and then click OK. Add a CommandButton, a TextBox, and a Toolbar control to Form1.  Add the following code to the General Declarations section of Form1: Option Explicit

Private Sub Command1_Click Toolbar1.Buttons.Add 2, "Ref1",, tbrPlaceholder Toolbar1.Buttons.Add 4, "Ref2",, tbrPlaceholder Text1.Top = Toolbar1.Buttons("Reference").Top + _ (Toolbar1.ButtonHeight - Text1.Height) / 2 Text1.Left = Toolbar1.Buttons("Reference").Left End Sub

Private Sub Form_Load Toolbar1.Wrappable = True Toolbar1.Buttons.Add, "Button1", "Button1", tbrDefault ' Add a placeholder Toolbar1.Buttons.Add, "Reference", , tbrPlaceholder Toolbar1.Buttons("Reference").Width = Text1.Width Toolbar1.Buttons.Add, "Button2", "Button3", tbrDefault End Sub

Private Sub Form_Resize ' set text boxes to placeholder positions Text1.Top = Toolbar1.Buttons("Reference").Top + _ (Toolbar1.ButtonHeight - Text1.Height) / 2 Text1.Left = Toolbar1.Buttons("Reference").Left End Sub  Run the project. Resize the form by clicking the mouse on the lower-right corner of the form and dragging it to the left until the Toolbar must wrap. The visual problem becomes readily apparent. Click Command1 and repeat the previous step. Note that the problem no longer occurs.</li></ol>

<div class="references_section">