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.