Handling Minimizing and maximizing a form

Is there a quick way to reset the controls on your form to look good when the user min/maximizes it?
Who is Participating?
mrmickConnect With a Mentor Commented:
When the min/max buttons are clicked, the resize event is fired.  Place a call to a procedure or code in there to handle redrawing the controls in question.

Inside the event procedure (or anywhere in the form code), you can determine the current state of the form by checking the "WindowState" property of the form.

Sample code:

   Select Case Me.WindowState
      Case vbMinimized
         MsgBox "Min Clicked"
      Case vbMaximized
         MsgBox "Max Clicked"
      Case vbNormal
         MsgBox "Normal"
   End Select

Note: In redrawing your form, you can use the Width & Height properties of the form to determine the current size of the form and use it to change control placement through the Left & Top properties of the controls in question.  You can also adjust the size of the controls through their Width and Height properties.
If you have a lot of controls on the form it would help if they were control arrays.  Refresh, works pretty good, refresh before the minimze/maximize.,
gptsAuthor Commented:
Could you be a little more specific?  I've tried doing the formname.refresh on formname_resize()....should I be changing the left positions of the control arrays?  
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.


You need to figure out (mathematically) how to place your controls on your form based upon the size of the form.
I can't really provide a concrete answer to this since I don't know what the form looks like.
gptsAuthor Commented:
what action is fired by the minimize/maximize buttons?  Do I have to change the left position of the control arrays?
there are third party controls to take care of this for you, not all work very well though.
gptsAuthor Commented:
Thank you.
Or u could just simply subclass the form and fetch the MIN and MAX messages sent to the window and act from that... you can read about subclassing at:


Yes, i post this site a lot but it's really good with source code for a couple of .OCX's =)
gptsAuthor Commented:
Thanks for everyone's help!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.