Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine When Form Has Finished Resizing

Status
Not open for further replies.

Auguy

Programmer
May 1, 2004
1,206
US
Are there any events or properties set when the resizing of a form is complete? What I'm trying to do is calculate new column sizes for a grid, but only have the calculations performed after the user stops resizing the form, not continually while the form is being resized. I've thought about using a timer and turning it on in the form resize event and keep resetting it as long as the resize event is firing. Then, after some small amount of time the timer would then call my column resizing method. Any help or guidance would be appreciated

Auguy
Northwest Ohio
 
Auguy,

My understanding is that the Resize event will only fire after the resizing is complete, not continually while the resizing is in progress.

But, even if I'm wrong about that, I wouldn't worry about it. Unless the calculations are particularly time-consuming, there's no harm in executing them repeatedly during the resizing process. I doubt if you'll notice any effect on performance.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Mike, you are probably correct about it not making much diference. I'm not so sure about the rezise only firing once though. I set up a simple form with a textbox on it and placed the following code in the resize method of the form.
Code:
Thisform.Text1.Value = Thisform.Text1.Value + 1
It's value gets updated many times even if I move the mouse as fast as I can. I don't think it will affect my project very much, but if you were trying to do a lot in the resize event, it could be a problem and you should find another way to fire your code. I'm going to play around with the timer idea, don't think it should be too hard to figure out.

Auguy
Northwest Ohio
 
OK, The following seems to work fairly well. Any comments or improvements are appreciated. I dropped a timer (Timer1) on my form, set it to initially disabled, and entered the following in the resize method of the form
Code:
Thisform.Timer1.Reset()
Thisform.Timer1.Enabled = .T.
In the Timer method of Timer1 I put the following code.
Code:
This.Reset()
This.Enabled = .F.
* Whatever code you want here
I tried various timer intervals and 100 (tenth of a second) seems pretty good while testing. This value allowed me to resize the form fairly slowly without firing the timer code. Will try it in my live form and adjust if needed. I probably will add some code to check to see if the form was minimized.


Auguy
Northwest Ohio
 
Auguy,

This is very interesting. I must admit I was surprised with the result of your textbox test. When I read your initial post, I tried something similar with a WAIT WINDOW ... NOWAIT, and couldn't see any evidence of the resize being continually fired. But that might be because of something specific to the WAIT WINDOW.

I have been coding Resize methods for years, and the issue of continual firing never occurred to me. Perhaps I should re-think the issue. On the other hand, I've never been aware of any performance problems with my code.

Please let us know if you discover any further information.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Like you said in your first reply, it probably doesn't make much difference unless you are doing some fairly intensive processing in the rezise method. If you are, you should probably find a different way of doing it. I put the
Code:
Thisform.Text1.Value = Thisform.Text1.Value + 1
in the resize timer to see what would happen. After doing some more testing, I think a timer interval between 50 and 100 seems about right. Only if you move the mouse very slowly does the timer fire and update the textbox counter while resizing the form. I think I will incorporate this in my project.

Auguy
Northwest Ohio
 
I've been coding resize methods and resizing columns in a grid for years without any problems or performance issues at all as long as your resize calculations don't generate invalid values for the column widths...

If you really want to hold off on the column size calculations until the user interaction is complete I think using the MouseDown event to flag the start of the resize, and the MouseUp event to flag the end of it would allow you to resize your columns after the user interaction is completed.

Andy Snyder
SnyAc Software Services Hyperware Inc. a division of AmTech Software
 
Thanks Andy, I might look into that. How would that work with the max/min button?

Auguy
Northwest Ohio
 
Add a logical property to the form (i.e. ll_sizeit) initial value of .T.

on the mouseDown event of the form set ll_sizeit to .F.

on the mouseUp event of the form set ll_sizeit to .T. and call the resize method.

in the resize method return before resizing anything if ll_sizeit = .F.

min button doesn't matter.... max button wouldn't fire resize until the mouse has come up anyway....

Andy Snyder
SnyAc Software Services Hyperware Inc. a division of AmTech Software
 
Looks Great. Thanks

Auguy
Northwest Ohio
 
That's an excellent idea, Andy. But I suppose you would also need to cater for the possibility of users doing the resizing or maximising via the keyboard rather than the mouse (though I'd be tempted not to bother).

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top