Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default stopping userform resize on minimize

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.

Hughie

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default stopping userform resize on minimize

See Bart Smissaert's solution, post #30 in his thread-view link

http://tinyurl.com/ylhzk7

Regards,
Peter T

"hughie" wrote in message
ps.com...
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.

Hughie



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default stopping userform resize on minimize

Suppose I should also have cited the example I posted in the same thread in
response to providing minimize/maximize for a modal form, though others
quite reasonably pointed out there doesn't seem much point in doing that
with a modal form!

Regards,
Peter T

"Peter T" <peter_t@discussions wrote in message
...
See Bart Smissaert's solution, post #30 in his thread-view link

http://tinyurl.com/ylhzk7

Regards,
Peter T

"hughie" wrote in message
ps.com...
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.

Hughie





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default stopping userform resize on minimize

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?


well, when the UserForm_Resize() event fires during a minimize, I'm
getting a runtime error (308, property less than zero) because the code
tries to set control heights and widths in relation to 'me.height' and
'me.width'.

What I discovered through your 'debug.print' technique which I had
forgotten about, was that the 'me.height' property was reporting itself
as 23.25 and later I was subtracting 41 from it generating the runtime
error.

Therefore, all I've done is check for a value just over the one it
thinks it is during a minimize event (why is it 23.25? go figure) ie:

If Me.Height < 25 Then Exit Sub

...and all is well.

Much appreciated all your help. Isn't it a nice thing that folk take
the time and trouble to help out :)

gasho,
Hughie

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Minimize button on userform? Bob Excel Discussion (Misc queries) 3 June 13th 09 11:01 PM
Minimize UserForm Howard31 Excel Discussion (Misc queries) 0 December 17th 08 09:10 PM
VBA - need to minimize Excel from UserForm gary Excel Programming 3 June 3rd 06 10:41 AM
Minimize a UserForm SailFL Excel Discussion (Misc queries) 1 August 21st 05 12:45 AM
How to minimize a userform! furbiuzzu Excel Programming 4 June 15th 05 07:46 PM


All times are GMT +1. The time now is 10:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"