Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Easy Question about Form Release
Message
 
 
To
17/05/2005 19:29:06
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01015143
Message ID:
01015183
Views:
19
Christopher,

You should avoid trying to work with hard memvar names like this. For one thing they break down horribly in a multiple form instance scenario.

It's best to hand a reference around between your forms, or alternatively a unique name that can be looked up via your FormsManager object or the _screen.Forms[] collection.

Your frmChart form should call the frmEditPat form like this:
do form "editpat" with thisform && or thisform.cUniqueName
In your frmEditPat.Init:
lparameter loParentForm && or cParentFormUniqueName

this.oParentForm = loParentForm
When you want to go back to the parent form:
this.oParentForm.ReturnFocus()
This would call a custom method of your form and it should set focus as it decided. This helps because now your child form doesn't know anything about the internals of the calling form. If you ever changed the name of the listbox to something more meaningful like lstPatients your child form would error out because list1 no longer exists.

To find a form in the _screen.Forms collection you can do something like this:
* Your lowest level form subclass .Init()
this.cUniqueName = sys(2015)
This gives each form a unique identifier as it starts running. Then to look for it:
for each loForm in _screen.Forms
   if ( loForm.cUniqueName == lcSearchedForName )
      loForm.BackColor = rgb( 255, 0, 0 ) && you'd probably want to do something more useful *g*
   endif
endfor
>I have one form (called CHART1) on which there is a listbox. When one double clicks on the list box, another form (EDITPAT) opens to allow user input. The EDITPAT 'OK' button has the following in the 'Click' method:
>
>thisform.release
>CHART1.list1.setfocus
>
>to specifically send the focus back to the listbox on the first form. When I run the code, and press the 'OK' button in EDITPAT, I keep getting the error message "Object CHART1 is not found".
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Reply
Map
View

Click here to load this message in the networking platform