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

object.visible from menu

Status
Not open for further replies.

Shane1961

Programmer
Oct 1, 2015
14
0
0
AU
Hi all.
I am trying to make visible a container within a form, from a menu.
Thisform.object.visible-.t. does not work.
Any help please.
 
In VFP, the menu is not an object contained in the form.
For this reason you can't use Thisform.

You have multiple choices. I believe the following list is not exhaustive.
- you can launch the form using the Name clause
do form whatever name variablename
- you can use _screen.activeform (not always)
- you can query _screen.forms
- you can store the form reference into a public variable, or a property of a public (variable) object
- you can store the form reference into a custom property of _screen
- you can pass form's reference to the menu / menu item, if the menu is defined inside a method of the form, like :
local ofrm
ofrm = ThisForm
...
on selection whatever... do myprocedure with ofrm


Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
I would favour Vilhelm-Ion's first option. Use the NAME clause to get an object reference to the form; and then keep that reference in scope, for example in a public variable.

When launching the form:

[tt]PUBLIC goMyForm
DO FORM MyForm NAME goMyForm[/tt]

Then, in your menu code:
[tt]
goMyForm.MyObject.Visible = .T.[/tt]

Using public variables is not the ideal way of keeping a variable in scope, but I used it in this example for the sake of simplicity.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thank you Vilhelm-Ion and MikeLewis.
I decided on DO FORM with MODAL as it is essentially a utility form that will not be accessed often.
One less Container. :) The information you provided will be useful in the future i'm sure!
Thanks again.
Shane.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top