I've got you covered. Here is a better way to approach this.
First off, you don't want to keep a single global-variable results window.
That gets tricky when you want to have more than one of them. Instead, I would
keep a global array called maybe @ResultsWindow (to keep with your naming
scheme).
When you want to create a new Results Window, you would do this:
push(@ResultsWindow, new GUI::Window( ....... );
Use some ideas from Jeremy White's code as for deciding what to name each
window.
When you're ready to close a window, the best thing I've found is to make a
_Terminate event, and if you want a button, have the button call the _Terminate
event, like so:
sub Window_Terminate {
# Free up any resources, disconnect sockets, etc
# ...
# ...
return -1;
}
sub WindowCloseButton_Click {
return Window_Terminate();
}
The "return -1" tells Win32::GUI to delete the widget that initiated the
subroutine call, in this case it will free the Window's resources and delete
the Windows GUI object.
I haven't tried it, but you might even be able to name the windows the same
thing, so that the _Terminate and _Click events can be hardcoded into your
source, instead of eval'ed in.
Sorry I don't have time to get more detailed on this, perhaps I'll send a
complete example in a couple days.
Trevor S Garside
[EMAIL PROTECTED]
-----Original Message-----
From: Cruickshanks, Darin [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 30, 2003 12:06 PM
To: Perl-Win32-Gui-Users
Subject: RE: [perl-win32-gui-users] Keeping track of child windows
Well basically the MainWindow has a button to create a results window and by
design I want it to be able to create more than one window with results (for
camparison etc).
The new results window is created like this -
$ResultsWindow = new GUI::Window(
-title => "Results",
-left => 400,
-top => 100,
-width => 185,
-height => 360,
-style => WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU ,
-name => "ResultsWin",
);
I then add a text area and a 'Close' button to this window.
The close button is added like this -
$ResultsWindow->AddButton(
-name => "Close",
-text => "Close",
-left => 5,
-top => 5,
-tip => "Click here to close the results view",
-cancel => 1,
);
The subroutine for the click event looks like this -
sub Close_Click {
$ResultsWindow->Hide();
}
The reason I use hide if because I dont know of a better way of getting rid of
Windows?!
Clicking the close button then closes the last window created.
Help?
Darin
--------------------------------------------
Darin Cruickshanks
Labs Manager, Computing Service
University of Essex
[EMAIL PROTECTED]
01206 873585
-----Original Message-----
From: Garside, Trevor [mailto:[EMAIL PROTECTED]
Sent: 30 April 2003 14:05
To: Perl-Win32-Gui-Users
Subject: RE: [perl-win32-gui-users] Keeping track of child windows
Can we get some sample code to see how you're handling the window creation /
closing?
Trevor S Garside
[EMAIL PROTECTED]
-----Original Message-----
From: Cruickshanks, Darin [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 30, 2003 8:43 AM
To: Perl-Win32-Gui-Users
Subject: [perl-win32-gui-users] Keeping track of child windows
All,
I have a gui window that can spawn multiple child windows, each with its own
'Close' button on it. The close button works fine if there is only one child
window but fails to work if there are more than one. I understand why this is
happening but cannot think of a good way around it!
Anyone have any ideas or can point out the obvious?
Cheers,
Darin
--------------------------------------------
Darin Cruickshanks
Labs Manager, Computing Service
University of Essex
[EMAIL PROTECTED]
01206 873585
-----Original Message-----
From: Peter Eisengrein [mailto:[EMAIL PROTECTED]
Sent: 25 April 2003 13:02
To: Cruickshanks, Darin; Perl-Win32-Gui-Users
Subject: RE: [perl-win32-gui-users] Perl and printing
There may be a better way, but here are two possible ways:
### THIS WILL BRING UP THE SAME PRINT WINDOW AS USED BY WEB BROWSER
$dll = "$ENV{'WINDIR'}/System32/mshtml.dll";
system("rundll32.exe $dll,PrintHTML $file");
-OR-
### THIS MAY OR MAY NOT GIVE THE BEST RESULTS
system("copy $file \\\\ServerName\\PrinterName");
Good luck.
-----Original Message-----
From: Cruickshanks, Darin [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 24, 2003 11:12 AM
To: Perl-Win32-Gui-Users; [EMAIL PROTECTED]
Subject: [perl-win32-gui-users] Perl and printing
All,
I have a Perl application that uses Win32::GUI to provide a nice front end for
a database, what I would really like to do is provide a print feature with the
ability to print to a network printer through the gui. Does anyone know of any
way to do this?
Cheers,
Darin
--------------------------------------------
Darin Cruickshanks
Labs Manager, Computing Service
University of Essex
[EMAIL PROTECTED]
01206 873585