Attached is my second Win32::GUI script (and my first go at events)...
There are two things I don't feel I've got right. First, in the Resize
event code, I am referring to the global variable $main directly. Is
there a way to get at "the window/control to which this event applies"
*without* needing to know global variable names, etc. Longer terms, I'm
thinking of things like
*{"${name}_Resize"} = sub {...}
to assign generic code to events.
Second, the given code flickers dreadfully. Presumably because I am
resizing the window in the resize event. Can this flicker be avoided?
Thanks for the help. I *will* write up my experiences.
Paul.
PS A nasty gotcha I hit was new Win32::GUI::Window(-name => "Main"
-width => 250, -height => 250) [note the lack of comma between "Main"
and -width]. This goes horribly wrong, because Perl sees string minus
bareword, and accepts it, followed by the wrong number of remaining
parameters.
--- test.pl
use Win32::GUI;
$main = new Win32::GUI::Window(-name =>"Main", -width => 250, -height =>
250);
$main->Show();
Win32::GUI::Dialog();
sub Main_Terminate { -1; }
sub Main_Resize {
$main->Width(500) if $main->Width() > 500;
$main->Height(500) if $main->Height() > 500;
}