At 17:56 2002-01-20 +0000, Pete wrote:
I'm trying to get a routine running as either a subroutine or more ideally
an object(using strict and diagnostic). It works fine if it is all in the
main body but once I put it in a subroutine It generates errors when trying
to access the subroutine called from the "button Click" subroutine. So far I
can't see any way round this. I have include an extract below. Thanks in
advance.
I think I see what you are trying to do, but please post the entire piece
of code to clarify the situation.
Basically, the problem with Win32::GUI event handlers is that there is no
context (i.e. an object) passed to them when the event is fired. So you
need to keep track of the Win32::GUI object yourself. The easiest way to do
that is in a global var of some sort. If you think that sucks/is poor form,
well yes you're right. Deal with it :)
Also, since it looks like you're using modules it might be good know that
event handlers are (almost) always located in package main. Consider this code:
package MyMod;
#This will never be called
sub winMain_Terminate {
return(-1);
}
#This will be called
sub main::winMain_Terminate {
return(-1);
}
#This is the same as package main
sub ::winMain_Terminate {
return(-1);
}
If you want to put a window/control in another package, set the -name
option like this:
-name => "MyModule::ControlName"
But that makes accessing the control a bit difficult (but not impossible).
/J
-------- ------ ---- --- -- -- -- - - - - -
Johan Lindström Sourcerer @ Boss Casinos [EMAIL PROTECTED]
Latest bookmark: "What does efficient mean!"
<http://www.perlmonks.org/index.pl?node_id=138919&lastnode_id=140162>