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

Menu and Form

Status
Not open for further replies.

Lengliz

Programmer
Feb 15, 2005
29
TN
Hi,
I have a Command Button ("Command1") on a top level form ("Form1"),
My question.. How can I control this command Button from the menu?
for example to make it visible or not:

..Form1.command1.visible=.T. or .F.

Please Help.
 
When you launch the form, you need to grab an object reference to it:

Code:
DO MyTopLevelForm NAME goForm

goForm will hold the reference to the form.

This variable must remain in scope while the form is open. One way to do that it to make it a public variable. Set the public variable initially to NULL. (Using public variables is generally frowned on, and there are better ways of achieving the goal, but let's keep things simple for now.)

So do this at the start of your main program:

Code:
PUBLIC goForm
goForm = NULL

Now, in your menu command, you can refer to the command button like this:

Code:
IF NOT ISNULL(goForm)
  goForm.Command1.Visible = .T.
ENDIF

Give it a try.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top