On 16/08/2007, Perl Rob <[EMAIL PROTECTED]> wrote: > Well, I answered my own question, so I thought I'd post the answer > in case it helps someone else who wants to close a window in this > manner. Turns out I had to create a quoted word list and add > WM_CLOSE to it (as a part of my "use Win32::GUI" line): > > use Win32::GUI qw( WM_CLOSE ); > > > To be perfectly honest, I don't understand *why* that fixed the > problem, but it did. I couldn't get any windows to close until I > did that—now I can close any window (that allows it) by finding > its handle and sending it the WM_CLOSE message.
That's the syntax for getting Win32::GUI to import constants into the caller's namespace (in fact it's a very common perl syntax in general). Read the documentation for Win32::GUI::Constants for more information. If you had a 'use warnings;' line, then your earlier attempts would have given you more information about why they were not working. [As an aside you shouldn't blindly assume that sending a window a WM_CLOSE will close it - an application is perfectly entitled to catch the WM_CLOSE message and not close the window - for example many programs catch the WM_CLOSE and pop up a dialog asking whether the user really wants to exit (annoying, but it happens) - this is perhaps more useful if the application is reporting that there are unsaved changes and asking if the user wants to save them before exiting.] Regards, Rob. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Perl-Win32-GUI-Users mailing list Perl-Win32-GUI-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users http://perl-win32-gui.sourceforge.net/