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

Accessing alternate form methods using form name as variable 3

Status
Not open for further replies.

MitchUK

Programmer
Jan 17, 2001
22
GB
I have been dumped with someone elses project who have created a master menu form to access other forms within an application.

I need to be able to access other forms' methods using this master form but the only reference I have at the moment is the &Myform variable.

Is there a way to access methods of a form which is not set as the top (or active) form and switch the focus to that form??

Previous applications I have written (in Delphi) allow you to access the method of another form without making it the active form, is this possible in foxpro???
 
Yes, it is possible. I assume the other forms have been instantiated and you have an object reference to them; if the desired form has not been instantiated, you can use the DO FORM ... NAME ... NOSHOW command to instantiate it but not display it.
Robert Bradley
 
Yes, you can access other forms' properties and methods, but you need to know the specific form's object "name" (not the form's name property, since there could be multiple objects with the same name property). Normally an application that was planning on using the capability, would have a Forms manager that keeps this information in a public array or application object. Obviously the details of your solution depend on how your application was designed.

Rick
 
Visually, the top 3cm of the main foxpro window contains an option group of 24 buttons for the user to select one of a mutilple of forms (and tables) but only one form (apart from the optiongroup form) is visible at any one time.

I have to write some code to reference whichever form is visible (but not WINTOP() and not in use) and I would like to reference a user defined method which I can add to all forms to enable this.

If I wrote this myself I probably would have used formset or pages within one form to allow easy access to methods, but I have inherited this software from a previous employee.

So how can I access a forms method, only using the handle for the form stored in tha variable &myform??

&Myform is accessed using: ACTIVATE WINDOW &MYFORM

I wish to access using (with my knowledge of other SDK's would be something like &myform.method() but I am fairly unfamiliar with FoxPro at the moment)

I know it's long winded but any ideas???
 
Thanks to Foxdev and Rgbean, who didn't give me the answers but let me know I wasn't barking up the wrong tree. After searching through all of the current threads I got enough pointer to work out the solution to my problem :


activate window &mywindow && grabs the current forms handle
do form &mywindow && sets the handle and accesses as Window ONTOP
messagebox(wontop()) && Double checks the form is ontop
&mywindow..mitch && mitch is a new user defined method
 
Did you tried _Screen.ActiveForm?
In addition, you overuse '&'.
Example for your code:

activate window (m.mywindow)
do form (m.mywindow)

if type("_Screen.ActiveForm") == "O" && just included it to
&& show how to check if ActiveForm is valid object
if PEMSTATUS(_Screen.ActiveForm,"mitch",5) && check
&&if 'mitch' is a member of active form
= _Screen.ActiveForm.mitch() && call it
endif
endif



Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Tomas,
I know the use of & is overused in this code, but this is the original code I have "Inherited", but thanks for the tip.

To one and all, thanx for the help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top