VB AniButton Control: Cannot Resize if PictDrawMode=Autosize

ID Number: Q82159

1.00

WINDOWS

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.

This information applies to the Animated Button custom control

supplied with Microsoft Professional Toolkit for Visual Basic

programming system version 1.0 for Windows.

More Information:

Steps to Reproduce Behavior

---------------------------

1. Run Visual Basic, or from the File menu, choose New Project (ALT,

F, N) if Visual Basic is already running. Form1 is created by

default.

2. 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.

3. 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

4. Add the following code to the Form_Click procedure:

Sub Form_Click ()

AniButton1.Caption = "This is a very very long caption"

AniButton1.PictDrawMode = 1 'Autosize control

'AniButton1.PictDrawMode = 0 'As Defined

'AniButton1.PictDrawMode = 2 'Stretches image to fit

End Sub

4. 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

5. Run the project with the PictDrawMode setting of 0 uncommented and

the other two commented out.

6. 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.

7. Access the Frame property and load a bitmap into the first frame

and an icon in the second, or vice versa.

8. Repeat steps 5 and 6. Notice that the larger object (the bitmap)

causes the control to resize to it.

Additional reference words: 1.00