Thanks Jeremy. I will wait for the next release. Right now I will use a global.
Emmanuel > --- Ursprüngliche Nachricht --- > Von: "Jeremy White" <[EMAIL PROTECTED]> > An: [EMAIL PROTECTED] > Kopie: perl-win32-gui-users@lists.sourceforge.net > Betreff: Re: [perl-win32-gui-users] Using Win32::GUI events within a class > or a package? > Datum: Tue, 20 Sep 2005 09:14:17 +0000 > > > >oh no! what i meant was something like this: > > > >sub StartClick > >{ > > my $self = shift; > > #Here $self is the button that was clicked. > > #How do I access the window that this button is part of? > > #I want to change certain parts of the window when the > > #button Start is clicked. > >} > > > >One way I figured out was declaring $window as a global variable. Then > all > >subroutines have access to it. > > > >Is there any other way? If the sub StartClick does not have access to the > >$window variable, is it possible to work back upwards from the button > $self > >and retrieve the window? And then modify parts of the window? > > Yes, there is another way, but... > > You'll either have to wait for the next version of win32-gui (which should > be soon), or build your own from CVS. There is a new method which can be > called on controls to return the parent window: GetParent, and a useful > associated method: UserData. So: > > sub StartClick > { > my $self = shift; > my $win = $self->GetParent; #returns a win32::gui window > $win->somecontrol->Text("Some string"); > } > > The UserData method is really useful as it allows you to assocate data to > a > window of control, allowing you to create an object from the window, with > instance data stored within the window. > > Cheers, > > jez. > > -- 5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail +++ GMX - die erste Adresse für Mail, Message, More +++