stopping userform resize on minimize
On Jan 8, 1:41 pm, "hughie" wrote:
Using Stephen Bullen's form fun, I've got a form minimizing (huzzah!)
but the UserForm_Resize event is not exiting when it should. ie, the
line:
If Me.InsideWidth = 0 Then Exit Sub
doesn't have an InsideWidth of 0 during a minimize (nor does it seem to
in his frmTest, but it still works, it shouldn't!).
..anyone know the syntax for trapping a minimize event? I tried
application.windowstate but was getting -4143 in all cases.
Application.WindowState is probably going to refer to Excel, not your
form, so it's not much use. From a quick check (I have Excel 2002 here)
a UserForm doesn't obviously expose a WindowState, which is annoying,
but unsurprising, since it doesn't naturally offer Minimize or
Maximize. Since a UserForm doesn't naturally support resizing anyway,
it kind of makes you wonder why the Resize event is there at all.
But using Stephen's CFormChanger to make the form Resizeable lets it
trap the event - go figure.
So I took a form, added CFormChanger to my project and put this code in
UserForm1:
Option Explicit
Dim mclsChanger As CFormChanger
Private Sub UserForm_Initialize()
Set mclsChanger = New CFormChanger
With mclsChanger
Set .Form = Me
.ShowMinimizeBtn = True
.ShowMaximizeBtn = True
.Sizeable = True
End With
End Sub
Private Sub UserForm_Resize()
Debug.Print "Resize", Me.Width, Me.Height
End Sub
Seems to me that UserForm_Resize() fires when I resize by dragging,
minimize or maximise. Isn't that what you wanted? What am I missing
here?
Mike
|