VB AniButton Control: Cannot Resize if PictDrawMode=Autosize

Last reviewed: June 21, 1995
Article ID: Q82159
The information in this article applies to:

- Professional Edition of Microsoft Visual Basic for Windows,

  versions 2.0 and 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 INFORMATION

Steps to Reproduce Behavior

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

  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
    
    

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

  6. Run the project with the PictDrawMode setting of 0 uncommented and the other two commented out.

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

  8. Access the Frame property and load a bitmap into the first frame and an icon in the second, or vice versa.

  9. Repeat steps 5 and 6. Notice that the larger object (the bitmap) causes the control to resize to it.


Additional reference words: 1.00 2.00 3.00
KBCategory: kbprg kbcode
KBSubcategory: PrgCtrlsCus APrgGrap


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.