Form Startup Position

  • Thread starter Thread starter kirkm
  • Start date Start date
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
 
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
 
Or, store the values when the form is first opened, do whatever you want
with the form, then reset using the stored values.
 
Back
Top