Form Startup Position

K

kirkm

If you've changed a Forms Height, Top etc. is there any way
to restore the design time defaults, without closing the Form and
opening it again?

Specifically I'm trying to force it back to center (StartupPosition =
1, Form Top = 0) after it's expanded, then shrunk again.

Thanks - Kirk
 
P

Peter T

With APIs you can work out the pixel size of the screen and the form and
center accordingly. However for your needs probably OK to simply trap and
restore its coordinates

' click the form
Private mLt As Single, mTp As Single

Private Sub UserForm_Activate()
With Me
mLt = .Left
mTp = Top
End With
End Sub

Private Sub UserForm_Click()
Static b As Boolean
With Me
.Left = IIf(b, mLt, 20)
.Top = IIf(b, mTp, 20)
End With
b = Not b
End Sub


Regards,
Peter T
 
T

Tim Zych

Or, store the values when the form is first opened, do whatever you want
with the form, then reset using the stored values.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Form Display 0
Save Form Position on Close 4
Word 2003 won't exit 8
Image Control Question 5
PowerPoint 2010 Control positioning problem 0
Form Position Chip Pearson 4
Help with simple user form 8
Comments 1

Top