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

Toolbars

Status
Not open for further replies.

sdocker

IS-IT--Management
Aug 12, 2010
218
GB
Hi,

Is it possible to adjust the height of a toolbar. I can't seem to accomplish it and am wondering why it is larger than the VFP ToolBars in the IDE.

Also, is it possible to keep the menu active when opening a FormSet. I understand I would have to control it with SET SKIP ......

Thanks,
Sam
 
Olaf,

I tried all you suggestions, but the form did not stay visible. What I did to keep them visible was as follows:

Make the forms modeless
Call them after making them public.
PUBLIC ofrmOne
DO FORM frmOne NAME ofrmOne LINKED

I still have to work on accesing the menu.

Sam




 
You need READ EVENTS in the main program after you set up the top-level form for your application.

Code:
* Lots of start-up code
DO FORM MyTopLevelForm
READ EVENTS

* Lots of clean-up code

Then, whatever item is supposed to stop your application should contain CLEAR EVENTS.

Tamar
 
Tamar,

My code follows the sequence you recommended.

This has turned into a big thread, so I'll take the liberty of recapping.

Basically, is it possible to call a form ,,modeless obviously, and still have the main menu active and enabled?

Sam
 
Yes, you can have a manu staying active while forms run.

You just have another problem with variable scope. If you start a form LINKED to a variable, it only exists as long as the variable exists. That's another reason besides a missing READ EVENTS your form just flashes and then disappears. The menu code ends and the variables you created are released, and so is the form.

Public variables stay in memory until you really RELEASE them, but are not really a solution. How about NOT using a variable at all?
Code:
DO FORM frmOne
That would work.

Do you need to access the form from outside via the variable? There are many valid reasons to have a reference to a form in a variable, but not just to keep it alive.
The best thing you can do is have a form handler starting forms, keeping track of them. And the simplest form handler is passive, it's just a collection object you add to _SCREEN, eg:

In main.prg do
Code:
_screen.addobject("oForms","Collection")

Then when starting a form do
Code:
DO FORM frmOne NAME loForm
_screen.oForms.Add(loForm)
Now it won't matter, whether loForm is released or not, the form is kept in the oForms collection.

It get's even simpler, if all your forms are based on a base form class, then you can let the form add itself to the collection. In the form INIT event do:
Code:
_screen.oForms.Add(THIS)

And the best thing is, if you close the form via the close button, or by doing Thisform.Release() in it, it's also automatically removed from the _sceen.oForms collection.

Try it.

Bye, Olaf.
 
Olaf has it nailed with variable scope, I suspect.

(This is why I wanted to see code.)

Having multiple forms running and clicking between them is VFP's default behavior. You have to *do* something to have it not happen. [bigsmile] Using the LINKED keyword with a variable that goes out of scope is that something in this case.
 
Dan is right, but just to clarify - the LINKED keyword doesn't hinder the clicking between forms, it just makes the form disappear as it's being linked to a variable not declared before, which creates a private variable. And private variables are out of scope and released right after the menu item command has finished, which also closes the linked form. It's a sign there is no modal form anymore.

If you have this as the command of a menu item you can think of the command as a procedure only having a single command. VFP creates private variables, if they aren't declared previously and so the LINKED clause creates a variable with private scope, and private scope variables are scoped to the currently running code and are released, when the code has finished, which is the case after the DO FORM is done. If you prevent the DO FORM to finish by making the form or formset modal the menu is blocked as the selected menu item code still runs.

As the form disappears, you now obviously don't have any modal form in your formset anymore, the forms just appear shortly and are released in the next moment, because the linked variable is released. You solved that by a PUBLIC variable, but you can also solve it in the two ways I showed, not creating a variable holding the form reference at all or storing them somewhere.

Bye, Olaf.
 
Thanks everyone,

All the advice got me on the right track. I have a bit more finessing to do, but progress continues.

Sam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top