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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to close all forms on the screen programmaticly?

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
Hi!
What is code to close all forms on a (VFP)screen programmaticly?
And, what method is used on the form for closing that form (for putting code in that method for proper closing a form.
-Bart
 
Hi Bart.

What is code to close all forms on a (VFP)screen programmaticly

Code:
FOR EACH loForm IN _Screen.Forms
  loForm.Release()
ENDFOR

But do be careful. If you happen to have a modal form being displayed that was called by another form that is waiting for a return value, you may have some rather unexpected results.

Marcia G. Akins
 

Bart,

Also, be aware that Marcia's code will also release toolbars, which might not be what you want. Plus, in earlier versions (3.0 and 5.0 if I remember right), toolbars didn't have a Release method, so you would have to test to see if the baseclass is "toolbar" to avoid an error.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Hi, Both Marcia and Mike,
The code does what it should do. Some background:
In my app there will be a kind of toggle-switch which enables the use of 'size to maxscreen' as described in 1001 things.
As a form has been resized there is currently no way to 'resize-back' to the original size other than instanciating again. The toggle-switch is part of the menu. Once a user wants to toggle he/she is informed that all windows will get closes which might be accepted or rejected. If accepted all window s will get closed.
Following Marcia's advice regarding modal-windows I am going to implement a feature which automaticly disable the menufeature as soon as the active method of a modal form did fire.
Mike I found indeed that also the toolbars were released, even if they were hidden. So I did some hardcoding to prevent them from ´unwanted´ release.
Will there be a way to recognize a form being a toolbar?
-Bart
 
Will there be a way to recognize a form being a toolbar?

Modify my code as follows to handle modal form and toolbar:

Code:
FOR EACH loForm IN _Screen.forms
  IF LOWER( ALLTRIM( loForm.BaseClass ) ) == [toolbar]
    LOOP
  ELSE
    IF loForm.WindowType = 1 && Modal
      EXIT
    ELSE
      loForm.Release()
    ENDIF
  ENDIF
ENDFOR


ENDFOR

Marcia G. Akins
 
In my app there will be a kind of toggle-switch which enables the use of 'size to maxscreen' as described in 1001 things.
As a form has been resized there is currently no way to 'resize-back' to the original size other than instanciating again. The toggle-switch is part of the menu.

Why? Why not just use the normal Windows maximize/restore facility and avoid all this difficulty?

Tamar
 
Tamar,
For your info. The method I borrowed from 1001 things is more than just expand the window to fullscreen.
It resizes all controls in fact it acts as kind of zoom. Meanwhile fullscreen is used.
-Bart
 

Bart,

The method I borrowed from 1001 things is more than just expand the window to fullscreen.
It resizes all controls in fact it acts as kind of zoom

I've never understood the point of that.

Surely, the whole point of resizing is to show more information. If you double the width of the window, you want to double the width of the texboxes, listboxes, and so on.

But with the code you are referring to, you also double the width of command buttons and option groups, and if you double the height, you also double the font size of the text boxes and labels. Why would anyone want to do that?

I'm curious to know what benefit this will bring you.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Mike,
I did work with fox-applications where the form was designed for 800x600 screen. I found it very silly to see that little window on a 1280x1024 screen. So in my opinion it's a nice feature to zoom the 'little-designed' window to max-screen size. But users must be able to remain with the original size.
Another benefit for my users (most 65+ persons) is that indeed lettering, buttons etc. are bigger and therefore easier to read/use by this category users.
-Bart

 
I have made a couple simple applications for friends that have vision issues and I use the VFP9 Resize Object Foundation class. It automatically resizes all controls and contents. I use two monitors each having a different resolutions for graphics work and when I change a form from one to the other I can resize it and it works really well.
 

Bart,

There's a difference between resizing and zooming.

If you have a form designed for 800 x 600, and you want to use it on a 1280 x 1024 screen, it makes perfect sense to resize it. That way, you'll see more information.

But does it make sense to zoom it? You only end up with the controls looking as they would if you were still running in 800 x 600.

As for the vision issues that Kstart mentioned, isn't that what Control Panel's screen settings are for?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Bart -- what version are you using? In VFP 9, you may find that the new Anchor property gives you the tools you need to handle this without having to use code.

Tamar
 
Hi Tamar,
Indeed using VFP9. But still got not enough time to figure out most of the new '9' features.
-Bart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top