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

Form not closing 2

Status
Not open for further replies.

beedubau

Programmer
Jan 7, 2003
97
AU
Background.

My App is designed in a Wizard metaphor. It has a Main form with a page frame which remains on screen until the [Quit] button is clicked.

From the pages of the page frame a variety of other forms and/or prgs are started.

Some of these forms appear in the debugger all the time whilst others that are called from a page do not even though they appear and in the Call Stack.

In one prg (which writes HTML pages) I use a 3rd party control to get the Exif tag values from image files.

The control is on a form (say 3p) and is used for each record as a table of image names and paths is scanned.

I am unable to close the form either after each use or after the end of the table and the end of that process.

Whilst I see the form on my screen on top of the last used sub form I cannot close it down.

Can anyone help with

1 When do forms appear in the debugger and when not?

2 Can I list the ojects that are open at any one time?

3 Is there a way of 'killing' any open form?

Regards

Bryan
 
1. depends how you call the form and some properties like WindowType, ShowWindow, Visible and others.

a) scx forms via DO FORM (has a NOSHOW option, if you use that you need to call it's Show method)

b) form classes via Createobject() - all objects are created visible=.f., no matter how the class or form is defined.

If you DO FORM a non modal form, and have no wait state, the form will vanish. As you have your main form and it works, that should be no problem.

The debugger shows you public and local variables and you can also watch THIS or THISFORM, but you need to have a breakpoint in the form to have access to it. Forms started with DO FORM without using the NAME clause are not even stored as some object reference in a variable, so you don't get a "grip" on it in the debugger. But there is always one grip: _screen.forms() is an array of all running forms, visible or not. _screen.forms.count gives you the highest array index. You can for example enter _screen.forms(1) in the watch window and can access it.

2. there is no central collection of everything. LIST MEMORY can list you all variables, _screen.forms() is an array of forms. AINSTANCES() can create an array of instances of a certain class. There are several starting points.

3. If a form stays open, there is something attached to it, which still lives and therefore the form cannot quit. In your case, if you create an activeX for each record, you prabably don't destroy these controls correctly, so the form still hangs. destroying something is best done by setting it to .null.

Bye, Olaf.
 
Thanks Olaf for your very detailed reply.

I use this etc to see my forms after a breakpoint.

I was not able to 'see' _screen.forms() array in the debugger.

I have written the contents of _screen.form.name(i)in a loop and clearly see my screens and that the 'problem' screen is not closing.

I have opened it with NAME.

I have tried myform.null() and myform = nul to no effect.

Would you please give me one more piece of guidance.

Regards

Bryan
 
.Null. is not a method, it's the NUL constant in VFP. You set a var holding an object reference to .Null. to destroy the object.

If you used the name clause it should be done like this:
Code:
Local myForm, result

Do FORM ... NAME myForm NOSHOW
myForm.SHOW(1) && modal form
*.. form runs until exited.
myForm.release()
myForm = .null.

In the form you would have some exit button doing thisform.release() or the user simply uses the X button.

If you don't want your form modal (which means it has focus as long as it runs), but want to enable the user to switch between forms, you need to use the NAME clause with something, which persists, not a local variable as above,
eg _screen.addproperty("myform") and then DO FORM ... NAME _screen.myform.

Otherwise the form won't show up at all, as it's destroyed together with the local variable.

Bye, Olaf.
 
Thanks Olaf for your tutorial.

I was creating a cursor within the form (with control which I was using later - thus it was still 'alive'. I converted the saving mechanism to an array and now the form closes in the normal way and the array is available later.

I am using this in another situation now also - many thanks for lighting the way!

Regards

Bryan
 
I was creating a cursor within the form
I was doing the same thing. Thanks for the post and Thanks Olaf for the answers.
In my case i used -
Code:
close databases all
cancel
clear events
quit
 
Hi white,

that is surely an app exit and is overcoming problems as dangling object references (zombi objects) by radically canceling and clearing all especially with quit. If you have such a problem with a subform, you can't do so, but need to solve the real problem.

Bye, Olaf.
 
but need to solve the real problem.
I changed the form from modal to modeless and the following worked fine. I hope this was the "real problem"
Code:
clear events
quit
Guess i'd better be reading up on all the nuances of the form types.
Thanks for the help
wjwjr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top