- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The two responses I got to a previous question were not too helpful, primarily because of my "knowledge level" (read "ignorance"). So forgive me if I ask again:
In my QuickWin application I have a callback routine used when the user selects File > Exit from the program's menu. I use this to remind the user to save files if needed. Works just fine.
However when the user clicks on the Title Bar X, or shuts down the computer from the task bar, my routine is bypassed, and the program shuts down with out giving the user the option of saving files!
How does one direct Title bar x or computer shutdown to transfer control to my routine??
In my QuickWin application I have a callback routine used when the user selects File > Exit from the program's menu. I use this to remind the user to save files if needed. Works just fine.
However when the user clicks on the Title Bar X, or shuts down the computer from the task bar, my routine is bypassed, and the program shuts down with out giving the user the option of saving files!
How does one direct Title bar x or computer shutdown to transfer control to my routine??
Link Copied
9 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is not my area of expertise, but I wonder if using SIGNALQQ with a request for SIG$TERM would do the trick.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need to handle a WM_CLOSE on the frame window. Here is a simple example:
program simple use dflib use user32 use kernel32 integer(LONG) f common /wininfo/ f external CatchClose !DEC$ attributes stdcall :: CatchClose print *, "Hello" f = SetWindowLong (GETHWNDQQ(QWIN$FRAMEWINDOW), GWL_WNDPROC, LOC(CatchClose)) if (f == 0) print *, "Error - unable to install close handler" pause end integer(4) function CatchClose (hwnd, msg, wparam, lparam) !DEC$ attributes stdcall :: CatchClose use user32 integer(4) hwnd, msg, wparam, lparam integer(LONG) f common /wininfo/ f if (msg == WM_CLOSE) then call MessageBox (NULL, "Put your close code here"c, "Closing..."c, MB_OK) end if CatchClose = CallWindowProc (f, hwnd, msg, wparam, lparam) return endJames
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
James,
Is you recommended procedure OK in QUICK WIN?
PAUL
Is you recommended procedure OK in QUICK WIN?
PAUL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You bet.
James
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Very Good!!
The post by James indeed works if the user calls for an exit via the X on the title bar. THANKS
BUT If the user does a computer shutdown the "save File?" warning is not invoked. This is not a show stopper but it would be nice if the Shutdown were trapped. Any suggestions?
PAUL
The post by James indeed works if the user calls for an exit via the X on the title bar. THANKS
BUT If the user does a computer shutdown the "save File?" warning is not invoked. This is not a show stopper but it would be nice if the Shutdown were trapped. Any suggestions?
PAUL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
See my answer above - I think that's what you need for a termination handler.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Paul,
You can catch a shutdown by adding something like
You can also "vote down" the shutdown to make sure you get your question answered, then either allow the user to re-initiate shutdown manually or do a shutdown yourself. Depends on how important you think your interaction with the user is.
James
You can catch a shutdown by adding something like
else if (msg == WM_ENDSESSION) then call MessageBox (NULL, "Put your end session code here"c, "Closing..."c, MB_OK)after the WM_CLOSE branch in the example I provided. However note that Windows will bring up the "Program is not responding" message if you don't complete whatever you are doing within a few seconds, not wonderful for user input.
You can also "vote down" the shutdown to make sure you get your question answered, then either allow the user to re-initiate shutdown manually or do a shutdown yourself. Depends on how important you think your interaction with the user is.
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think WM_QUERYENDSESSION is the better message to handle -- it is sent before WM_ENDSESSION to "ask the application about its opinion" (the WndProc should return 1 if it agrees). However, I didn't verify whether it has timeout period.
Jugoslav
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There won't be much difference as QM_QUERYENDSESSION also has the timeout period.
James
James

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page