David,
>QueryUnload() is called when the X is clicked. By time Destroy() and Unload()
Yes, now I know it (Fred told me). I put here two lines of code:
NODEFAULT
THIS.HIDE()
and my form hides as I want. I also found that without NODEFAULT my form doesn't hide (not always, to be precise).
fire there are no controls left they've already been destroyed. The only time I ever put code in Unload() is to RETURN the value for a modal form that is launched with
do form xyz to theReturnValue.
Ok. Where do you usually clean the garbige (I mean, close cursors, etc.)? In which method? I do it now in Unload method and in Release method of my main form I just release all my forms (main and 2 child). I modified my code a little:
In my main program I declare 2 global variables: chForm1 and chForm2. In the Init method of each of my child form I set chForm1(or 2)=THISFORM and in RELEASE method of my main form I just wrote chForm1(or 2).RELEASE() Of course, I check before is chForm1 an object and NOT NULL. This code also works fine. (Before I tried your code and Fred's code, they also worked fine)
Is there a particular reason you are calling Hide()?
Yes, as I said, I don't want to load/unload forms all the time, just the first time and then show/hide.
Now the problem is solved and I will use this approach in other applications. I have a new project now.
Thanks a lot for your helpful advises.
>>David,
>>
>> I tested my form again and again and found new problems:
>> First of all, I don't know what event occurs when a user clicks on close button of the form (I mean the close button on the right upper cooner of the form). I tried Destroy, Unload, other - all unsuccessfully. If I close my forms using special close buttons "Cancel" (thisform.hide()) all work, but if I close my form using the right cooner close button, my form unloads (I mean my second form, which I want just hide not unload):(.
>>
>> The second problem that I discovered is that sometimes (I have not catched the sequence of clicking yet) when I released my form I had an error message: "Can not access selected table".
Now I place tableupdate() into unload method of my form (it was before in release method) and I don't see this error. But I am not sure that this is a solution.
What do you think about this?
If it's not broken, fix it until it is.
My Blog