Can I delay windows automatically shuting down my app?

F

Frank

My program gets a WM_QUERYENDSESSION message and asks the user if it is OK
to shutdown.

While he's thinking about it, Windows displays a box saying the program is
not responding, and if not answered shuts down my program.

I need to delay that while until the user answers my program's dialog box.

How does Windows check to see if an app is responding.

Can I either make windows satisfied that my program is responding
or specify a longer time before it displays its box
or increase the time its box is displayed before it automatically shuts down
my app?

Thanks for any help
 
T

Tom Widmer [VC++ MVP]

Frank said:
My program gets a WM_QUERYENDSESSION message and asks the user if it is OK
to shutdown.

While he's thinking about it, Windows displays a box saying the program is
not responding, and if not answered shuts down my program.

Responding usually means processing messages.
I need to delay that while until the user answers my program's dialog box.

How does Windows check to see if an app is responding.

I think it fires messages to the window and waits for a response. No
response within a reasonable period == not responding. In this case, the
message is WM_QUERYENDSESSION, and that's a problem for you I think,
since the whole point is that you need to delay responding to that
message until later.
Can I either make windows satisfied that my program is responding
or specify a longer time before it displays its box
or increase the time its box is displayed before it automatically shuts down
my app?

One solution is to respond immediately to the WM_QUERYENDSESSION by
returning FALSE (abort shutdown), and then initiate the same kind of
shutdown that had already been initiated once the user has responded to
your message (actually, I'm not sure whether you can work out whether it
was a restart or a plain shutdown).

I don't know of a way to change the OS delay you mention - there may be
a registry key somewhere for it.

Tom
 
B

Ben Voigt

One solution is to respond immediately to the WM_QUERYENDSESSION by
returning FALSE (abort shutdown), and then initiate the same kind of
shutdown that had already been initiated once the user has responded to
your message (actually, I'm not sure whether you can work out whether it
was a restart or a plain shutdown).

Users *hate* that behavior, they expect that if they click logout and walk
away, the computer will be logged off when they come back.

Find some reasonable default behavior, like saving all open files with an
alternate name (append .autosave or .leftopen to the filename). Then, if
the user hasn't responded to your prompt by the timeout, execute the default
behavior and quit.

http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/regentry/34637.mspx?mfr=true

Note that if AutoEndTasks is set you need to give up on waiting for the user
with time to spare for your own processing or I/O, otherwise your app will
be rudely terminated.
http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/regentry/34637.mspx?mfr=true
 
F

Frank

Seems to me that this should be a common problem.
Many programs ask if you want to save before shutdown
I think, haven't really seen it lately

Thanks
 
F

Frank

Ben Voigt said:
Users *hate* that behavior, they expect that if they click logout and walk
away, the computer will be logged off when they come back.

I hadn't thought about that.
I'll look at the sites.

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top