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

QueryUnload event <> EXIT command button 1

Status
Not open for further replies.

xBaseDude

MIS
Jan 31, 2002
357
US
Gents....

I have a form that is called like this....

PUBLIC okb, okb_search && Create public variable for form ref
DO FORM kb NAME okb LINKED
READ EVENTS
DO myshutdown IN MAIN.prg

PROCEDURE myshutdown
ON SHUTDOWN && clear shutdown loop
CLEAR EVENTS
CLOSE ALL
QUIT
ENDPROC

In the QueryUnload code snippet I have...

DO myshutdown IN main.prg

On the form "kb" there is an "Exit" command button.
In the "click" event of the Exit button snippet I have...

DO myshutdown IN main.prg

To my humble but somewhat logical brain, these command should function the same. However clicking on the form/window "X" the form closes and exits immediately.
Clicking on the "Exit" command button does butkiss.

Why isn't Exit doin' the same thing as QueryUnload?

TIA - Wayne
sig_jugler.gif
...all this and tap dancing too!
 
Wayne, any particular reason why you're using the QueryUnload event?

The QueryUnload event does not occur if you issue the RELEASE command on the form in code or invoke the form's Release method.

In the Click() method of your exit button:

DO myshutdown in Main.prg
Thisform.Release

Al
 
Alan...

Wayne, any particular reason why you're using the QueryUnload event?

I just figured most users were like me, who occassionaly end a program by clicking on the windows "X".

I'm curious why you ask this question.

Thisform.release was the winning ticket!

Thanx Alan!

Regards - Wayne
sig_jugler.gif
...all this and tap dancing too!
 
Wayne:

My interpretation of a use, although not exclusive use, of QUERYUNLOAD is to analyze the value of the form's RELEASETYPE property (and other possible conditions), and then to allow or prevent the form's demise by invoking (or not) the NODEFAULT clause.

Perhaps others could add to this.

Often, clean-up activities are placed in the DESTROY event, when a form's destruction is certain.

There are a number of ways to make things work successfully, and you have done that!

Al

 
Alan;

I am curious tho...how the code jumps back to Thisform.Release

I would have thought the command stack would go something like this....

DO myshutdown in Main.prg

PROCEDURE myshutdown
ON SHUTDOWN && clear shutdown loop
CLEAR EVENTS
CLOSE ALL
QUIT
ENDPROC

(Thisform.Release ???)

I don't see how the code thisform.release is being executed *after* the QUIT command.

Isn't the command line...

DO myshutdown in Main.prg
being executed *immediately*

It seems to be going...

DO myshutdown in Main.prg
Thisform.Release
DO myshutdown in Main.prg

I mean I see your code working, but am at a total loss to see *why* it's working.

Regards - Wayne
sig_jugler.gif
...all this and tap dancing too!
 
Wayne, you needed to release the form.

Try creating a form with just a commandbutton on it. In the click event, enter WAIT WINDOW "TEST" and THISFORM.RELEASE. Click it.

Then, reverse the sequence of the 2 statements. No apparent difference in the outcome.

The form isn't released until everything in that event is executed.

As usual, there are different methods of achieving the same goal, but you can't have a form hanging in memory when the user's done with it.

You should probably also issue okb = .NULL. in myshutdown.

Al


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top