You have to free the form before setting the global pointer to nil. The reason you set it to nil is so you can use it to check if the form has been created already: If MyForm <> nil Then Myform := MyForm.Create(self).
If you set the pointer to nil before deleting it, you will get a GPF since it no longer knows the address of the form. Also, do not refer to self, use the global variable (Form name), exactly as I posted it. Mastapp has an example of the Screen.Forms code I posted for closing forms. Do a grep search on that if you're interested to see it. Dave --- "Jamie L. Mitchell" <[EMAIL PROTECTED]> wrote: > Just tried it quickly to make sure I still get the > error. > > In the OnClose event, I put in code to free the > dialog as follows: > > frmGlobalPointer := NIL; > Self.Free; > > The free seems to work until it gets to the > processing code that > called the OnClose (i.e. the button press or mouse > click that called > it.) At that point, an "Abstract Error" is > triggered. This makes > sense - the OnClose is called by a mouse or key > event which need to > finish after the OnClose event ends. Having freed > the form, the > control is no longer there to finish up. That has > always been the > problem that I have run into. > > jamie > > --- In [email protected], "Jamie L. > Mitchell" <[EMAIL PROTECTED]> wrote: > > > > Hmmmm- interesting. The MastApp that comes with > Delphi 2005 appears > > to be different. All forms are created at start > time - a grep search > > of the files show that they do not do that > anywhere. Same with the > > IPMastApp. > > > > jamie > > > > --- In [email protected], David Smith > <djsmith_1998@> wrote: > > > > > > Straight out of the Delphi manual (the > application > > > creates a global variable automatically as the > form's > > > name when you create a new form): > > > > > > > > > Put this in the form's OnClose event: > > > MyForm.Free; > > > MyForm := nil; > > > > > > To create it (from anywhere): > > > > > > If MyForm <> nil Then > > > MyForm := TMyForm.Create(mainForm) > > > > > > (I always make the mainform the owner unless > it's got > > > an obvious child relationship to something else, > that > > > way it always gets freed during a GPF situation) > > > > > > If you create more than one, you can make sure > > > you've freed them all by iterating through the > > > Screen.Forms variable looking for that class > type: > > > > > > For i := 0 to Screen.Forms.count-1 do > > > If Screen.Forms[i] is TMyform then > MyForm.close; > > > > > > See the demo's example under the folder: > > > demos/db/MastApp. In fact, that application has > an > > > example of many useful tips to use in your own > app. > > > > > > Dave > > > > > ____________________________________________________________________________________ Be a PS3 game guru. Get your game face on with the latest PS3 news and previews at Yahoo! Games. http://videogames.yahoo.com/platform?platform=120121

