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 > Perl-Win32-GUI-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users