From: Rogers, J. <rog...@oc...> - 2001-11-04 01:53:17
|
>Is there a message that Windows sends out? In that case, I could use >PeekMessage. Try windows mesages, WM_QUERYENDSESSION and WM_ENDSESSION You can read about them on MSDN or this usefull link I got from list awhile ago. <http://www.sxlist.com/techref/os/win/win32prg.htm> If you get this to work please post result. JohnR |
From: Sean H. <jal...@ho...> - 2001-11-04 19:34:19
|
I have not been successful. PeekMessage doesn't seem to work at all, and all I could get GetMessage to catch were menu clicks (my application has a NotifyIcon, but I never call Show on the main window). To solve my original problem, I simply have my application write to file each time a setting changes. An inelegant and inefficient solution, but it works. I think if something like the following were to be added to the main message loop in GUI.xs (perhaps between case WM_SYSCOMMAND and case WM_SIZE), it would work. case WM_QUERYENDSESSION: if(GetObjectName(NOTXSCALL hwnd, Name)) { /* * (@)EVENT:Shutdown() * Sent when Windows is about to shut down. * (@)APPLIES_TO:Window, DialogBox */ strcat(Name, "_Shutdown"); PerlResult = DoEvent_Generic(NOTXSCALL Name); } break; Then {WindowName}_Shutdown would be called whenever Windows is about to shut down. According to what I was able to discover, if an application returns false, Windows stops the shutdown process. So returning 1 or 0 should work as expected; I believe returning -1 from your sub would end the Dialog phase, but that Win32::GUI would then return a 1, so Windows would shut down. If anyone wants to test this out (I do not have a compiler), that would be nice. Perhaps it could be included in the next release if it works. Then, again, it's only really useful for something that runs during the entire Windows session, like my application or a daemon, so perhaps it's not really necessary. _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp |
From: Glenn L. <Gle...@ne...> - 2001-11-05 07:03:54
|
I'd sure like to see this capability (even if not this exact code) in a future release... Win32 GUI seems to deal better with shutdown on WinNT/2K than 9x. Sean Healy wrote: > I have not been successful. PeekMessage doesn't seem to work at all, and > all I could get GetMessage to catch were menu clicks (my application has a > NotifyIcon, but I never call Show on the main window). To solve my original > problem, I simply have my application write to file each time a setting > changes. An inelegant and inefficient solution, but it works. > > I think if something like the following were to be added to the main message > loop in GUI.xs (perhaps between case WM_SYSCOMMAND and case WM_SIZE), it > would work. > > case WM_QUERYENDSESSION: > if(GetObjectName(NOTXSCALL hwnd, Name)) { > /* > * (@)EVENT:Shutdown() > * Sent when Windows is about to shut down. > * (@)APPLIES_TO:Window, DialogBox > */ > strcat(Name, "_Shutdown"); > PerlResult = DoEvent_Generic(NOTXSCALL Name); > } > break; > > Then {WindowName}_Shutdown would be called whenever Windows is about to shut > down. According to what I was able to discover, if an application returns > false, Windows stops the shutdown process. So returning 1 or 0 should work > as expected; I believe returning -1 from your sub would end the Dialog > phase, but that Win32::GUI would then return a 1, so Windows would shut > down. > > If anyone wants to test this out (I do not have a compiler), that would be > nice. Perhaps it could be included in the next release if it works. Then, > again, it's only really useful for something that runs during the entire > Windows session, like my application or a daemon, so perhaps it's not really > necessary. > > _________________________________________________________________ > Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp > > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users -- Glenn ===== Due to the current economic situation, the light at the end of the tunnel will be turned off until further notice. |
From: Rogers, J. <rog...@oc...> - 2001-11-06 11:03:26
|
I tried this, it half works, When shutting down windows, it would appear that the Perl window terminates before executing the sub. I put a file write and a $wait=<>; in the $Win_Shutdown sub so I dont think I missed it. The Gui.xs mod works though, If I send a WM_QUERYENDSESSION message manually with Win32::GUI::Sendmessage then it works. I monitored the window with spy <00001> 04740150 S WM_QUERYENDSESSION nSource:0 (Logoff or Shutdown from Windows Security dialog) [wParam:00000000 lParam:00000000] Then the window responds only after after the sub finishes. <00002> 04740150 R WM_QUERYENDSESSION fShutdownIsOk:True [lResult:00000001] This is all on NT I am thinking that NT behaviour with this is different from 9x and I suspect that it might work with win 9x, but I dont have it handy with perl. If any one wants my binarys to try, drop me line off list. JohnR > I have not been successful. PeekMessage doesn't seem to work at all, and > all I could get GetMessage to catch were menu clicks (my application has a > > NotifyIcon, but I never call Show on the main window). To solve my > original > problem, I simply have my application write to file each time a setting > changes. An inelegant and inefficient solution, but it works. > > I think if something like the following were to be added to the main > message > loop in GUI.xs (perhaps between case WM_SYSCOMMAND and case WM_SIZE), it > would work. > > case WM_QUERYENDSESSION: > if(GetObjectName(NOTXSCALL hwnd, Name)) { > /* > * (@)EVENT:Shutdown() > * Sent when Windows is about to shut down. > * (@)APPLIES_TO:Window, DialogBox > */ > strcat(Name, "_Shutdown"); > PerlResult = DoEvent_Generic(NOTXSCALL Name); > } > break; > > Then {WindowName}_Shutdown would be called whenever Windows is about to > shut > down. According to what I was able to discover, if an application returns > > false, Windows stops the shutdown process. So returning 1 or 0 should > work > as expected; I believe returning -1 from your sub would end the Dialog > phase, but that Win32::GUI would then return a 1, so Windows would shut > down. > > If anyone wants to test this out (I do not have a compiler), that would be > > nice. Perhaps it could be included in the next release if it works. > Then, > again, it's only really useful for something that runs during the entire > Windows session, like my application or a daemon, so perhaps it's not > really > necessary. > > _________________________________________________________________ > Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp > > > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users |
From: Rogers, J. <rog...@oc...> - 2001-11-14 14:14:14
|
Marcus, The mod to GUI.xs does in fact work. Ive tested on, (or had it tested) Win95a/b and win98 works O.K windows will not shutdown untill shutdown sub has finished. WinNT40 and WIN2K non console app works O.K (e.g. run with wperl.exe) console apps (run with perl.exe) do not. NT has a different messages CTRL_SHUTDOWN_EVENT or CTRL_LOGOFF_EVENT-- AFAIK the console will die before WM_ messages occur... JohnR |
From: Marcus <li...@wo...> - 2001-11-04 10:28:22
|
On 04.11.01 at 12:52 Rogers, John wrote: >>Is there a message that Windows sends out? In that case, I could >use > >PeekMessage. >Try windows mesages, >WM_QUERYENDSESSION >and WM_ENDSESSION I found that information too once, but I don't know how to implement it. How do you use PeekMessage? Marcus |