Microsoft KB Archive/82159

= VB AniButton Control: Cannot Resize if PictDrawMode=Autosize =

Article ID: 82159

Article Last Modified on 2/23/2007

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Windows 2000 Readiness Analyzer

-



This article was previously published under Q82159



SUMMARY
Resizing an Animated Button custom control by setting the Width or Height property at run time will not work if the PictDrawMode property is set to Autosize (1). This is by design. When the PictDrawMode property is in autosize mode, the size is determined by the size of the images loaded, not by the design time setting of Width or Height nor the run time setting of those values.



Steps to Reproduce Behavior
 Run Visual Basic for Windows, or from the File menu, choose New Project (press ALT, F, N) if Visual Basic for Windows is already running. Form1 is created by default. From the Files menu, choose Add File. In the Files box, select the ANIBUTON.VBX custom control file. The Animated Button tool appears in the toolbox.  Add the following code to the Form_Load procedure: Sub Form_Load Form1.BackColor = &HFFFF00 ' To make the size of the control more ' visible. AniButton1.Move Form1.Width \ 4, 0, 1600, 1600 AniButton1.TextPosition = 3 ' Put caption at top for clarity. End Sub   Add the following code to the Form_Click procedure: Sub Form_Click AniButton1.Caption = &quot;This is a very very long caption&quot; AniButton1.PictDrawMode = 1  ' Autosize control. 'AniButton1.PictDrawMode = 0  ' As Defined. 'AniButton1.PictDrawMode = 2  ' Stretches image to fit. End Sub   Add the following code to the Form_DoubleClick event: Sub Form_DblClick Print AniButton1.Width AniButton1.Width = 400 Print AniButton1.Width Print AniButton1.PictDrawMode End Sub  Run the project with the PictDrawMode setting of 0 uncommented and the other two commented out. Click once to see the effect of changing the mode. Then double- click the form to see the changes due to changing the Width property. Because the caption is the largest object in an unloaded Animated Button, the autosize adjusts to it.</li> Access the Frame property and load a bitmap into the first frame and an icon in the second, or vice versa.</li> Repeat steps 5 and 6. Notice that the larger object (the bitmap) causes the control to resize to it.</li></ol>

Additional query words: 1.00 2.00 3.00

Keywords: KB82159

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.