From: Jeremy W. <jez...@ho...> - 2003-04-30 16:58:31
|
The way I dealt with multiple objects with the same name/functionality was to dynamically eval the events into main. Try the below code - it is a hacked job, and can be tidied up, but should give you a few ideas. Cheers, jez. use Win32::GUI; use strict; my $unique; my %resultswindow; for (1..5) { createresults(); } Win32::GUI::Dialog(); sub createresults { #create unique names $unique++; my $windownumber = $unique; my $windowname = "ResultsWin".$windownumber; $unique++; my $butname="Close".$unique; #create the window my $win = new GUI::Window( -title => "Results", -left => 400, -top => 100, -width => 185, -height => 360, -style => WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU , -name => $windowname, ); $resultswindow{$windownumber}=$win; #create the button $win->AddButton( -name => $butname, -text => "Close", -left => 5, -top => 5, -tip => "Click here to close the results view", -cancel => 1, ); $win->Show; my $string='sub ::'.$butname.'_Click {$resultswindow{'.$windownumber.'}->Hide();}'; print $string."\n"; #eval the sub into main eval $string; } >From: "Cruickshanks, Darin" <da...@es...> >To: "Perl-Win32-Gui-Users" <per...@li...> >Subject: RE: [perl-win32-gui-users] Keeping track of child windows >Date: Wed, 30 Apr 2003 17:05:50 +0100 > >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 >da...@es... >01206 873585 > > -----Original Message----- > From: Garside, Trevor [mailto:tr...@ga...] > 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 > tr...@ga... > > > -----Original Message----- > From: Cruickshanks, Darin [mailto:da...@es...] > 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 > da...@es... > 01206 873585 > > -----Original Message----- > From: Peter Eisengrein >[mailto:Pet...@at...] > 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:da...@es...] > Sent: Thursday, April 24, 2003 11:12 AM > To: Perl-Win32-Gui-Users; >per...@li... > 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 > da...@es... > 01206 873585 > > > _________________________________________________________________ Express yourself with cool emoticons http://www.msn.co.uk/messenger |