Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
VISUAL FOXPRO IDE >>  _SCREEN.ACTIVEFORM ... HOLD ON!

  Boudewijn Lutgerink
  Where is Boudewijn Lutgerink?
 Hoonaardstraat, Driel
 Netherlands
 Boudewijn Lutgerink



Just by accident I found this and wanted to let you all know.
Whenever you run a form from the command window you can access it like
_screen.activeform


Another option is to start the form like:
Do form MyForm name MF

You can then access it with MF.Controls(1).value = "someValue"

HOWEVER, I just found a shorter way.
so you start the form:
do form MyForm

You can now access this form simply with referring it as "MyForm".
So, assuming there is a property (SomeProp) on the form with a value in it you can now type
?MyForm.SomeProp.Value
to see the value of the textbox. Also, the IntelliSense works properly with this.
I tested this in VFP9, I do not know how previous versions will work with this.

FEEDBACK

Eric den Doop @ 4/16/2008 12:10:51 PM
I'm affraid this shorter way is going to get a bit nasty if you run multiple instances of the same form.

Eric den Doop @ 4/16/2008 12:20:01 PM
Oops.. hit the post button too soon... What I was trying to say is that if you run DO FORM MyForm more than once, the MyForm reference is only valid for the first instance. All other instances are there without a memvar reference. By specifying a unique NAME for each instance of that form, you have a reference for all instances, not just the first.

Andy Kramek @ 4/16/2008 2:07:56 PM
Sorry Boud but this is NOT a good idea!

Apart from the multiple instance issues, you have also got the issue that if you do this in the command window the reference is created, like all variables, as PUBLIC. Anywhere else it is private and so you cannot acces it.

If you must reference a form use a unique name and use the DO FORM .... NAME ... command.

This shortcut will bite you!

Boudewijn Lutgerink @ 4/22/2008 5:16:55 PM
Sure enough if one runs multiple forms this is not quite way to go, I agree completely.
However, in testing a form I never run the same form more than once.
In that situation you can use the idea I posted here. Eric and Andy are right about this. Tx BTW abdy to make my name a four letter word, it gives the feeling that I am on an equal level with you ( 4 letter name) and eric (likewise)


Boud

habib K @ 8/28/2008 4:43:07 PM
i'm agree with you, but if you run the same form with differente name where 'll be the probleme
Do form MyForm name MF
Do form MyForm name MF1
Do form MyForm name MF2
and then you can manipulatig form just with mf1.someprop.value.......
or am i wrong????

Wade Davis @ 11/15/2008 10:40:32 PM
If you don't use the 'Name' reference, vfp makes the name of the form the 'Name'.... makes sense.... works in vfp6



Your Name: 
Your Feedback: 

Spam Protection:
Enter the code shown: