VB AniButton Control: Cannot Resize if PictDrawMode=Autosize
ID: Q82159
|
The information in this article applies to:
-
Microsoft Visual Basic Professional Edition for Windows, versions 2.0, 3.0
-
Microsoft Professional Toolkit for Microsoft Visual Basic programming system for Windows, version 1.0
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.
MORE INFORMATIONSteps 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 = "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
- 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.
- Access the Frame property and load a bitmap into the first frame
and an icon in the second, or vice versa.
- Repeat steps 5 and 6. Notice that the larger object (the bitmap)
causes the control to resize to it.
Additional query words:
1.00 2.00 3.00
Keywords :
Version : WINDOWS:2.0,3.0; :1.0
Platform : WINDOWS
Issue type :
|