The subs are called by events, such as Click, RightClick, etc. Any handle such as Hello (which in this case is defined as the name of the button) can have one or more of these actions assigned to them. The convention for these subs is Name_Event where _Event is appended to the widget's name, i.e. Hello_Click is run when Hello (the button) gets a single click from the user.

HTH,
Pete

> -----Original Message-----
> From: Gossett, Malachy [mailto:mal.gossett@vector.com]
> Sent: Monday, August 26, 2002 13:33
> To: perl-win32-gui-users@lists.sourceforge.net
> Subject: RE: [perl-win32-gui-users] first app ?
>
>
> Johan, that is a pretty good explanation.  I'm a bit new to
> Win32::GUI,
> having used TK more, but never became a super user with it
> either.  Once
> question I have, I notice that subroutines don't need
> specific calls, so
> how do they get called.
>
> A perfect example would be the hello.pl from th 665 source
> release.  How
> are the subroutines being called in this?
>
> Thanks
>
> Mal
>
> use Win32::GUI;
> $MW = new Win32::GUI::Window(
>     -title   => 'hello.pl',
>     -left    => 100,
>     -top     => 100,
>     -width   => 150,
>     -height  => 100,
>     -name    => 'MainWindow',
>     -visible => 1,
> );
>
> #Add controls
> my $label = $MW->AddLabel(-text => "This is my text.",
>                             -font => $font);
>
> $hello = $MW->AddButton(
>     -text    => 'Hello, world',
>     -name    => 'Hello',
>     -left    => 25,
>     -top     => 25,
> );
>
> $MW->Show();
> $rc = Win32::GUI::Dialog(0);
>
> sub MainWindow_Terminate {
>     $MW->PostQuitMessage(1);
>     # return -1;
> }
>
> sub Hello_Click {
>     if($MW->Hello->Text eq "Hello, world") {
>         $MW->Hello->{-text} = "OneMoreTime";
>     } else {
>         print STDOUT "Hello, world\n";
>         $MW->PostQuitMessage(0);
>     }
> }
>
>
> -----Original Message-----
> From: Johan Lindstrom [mailto:johanl@bahnhof.se]
> Sent: Monday, August 26, 2002 10:21 AM
> To: perl-win32-gui-users@lists.sourceforge.net
> Subject: Re: [perl-win32-gui-users] first app ?
>
>
> At 08:03 2000-08-27 +0300, raptor@unacs.bg wrote:
> >I've just installed win32::gui but how i will do my first
> app if I try
> >this :
> >
> >use Win32::GUI;
> >my $w = new Win32::GUI(-name => 'XX');
> >$w->Show();
> >
> >But the window just got created and destroyed imedietly !?! Why this
> >happen ?
>
> Unlike your vanilla Perl program, most event based programs
> run what's
> called a main event loop. A GUI is most often event based. It
> means that
>
> you start it, and then it sits there waiting for user input (events,
> like
> mouse clicks on buttons, or timers being triggered).
>
> In Win32::GUI, you enter the main loop by calling
> Win32::GUI::Dialog(),
> so
> you should add that to your program, after the Show().
>
> Before entering the main loop you should have created all your windows
> (and
> Show():ed the ones you want visible from the beginning). In most cases
> you
> should never call Win32::GUI::Dialog() more than once in your program.
>
> After you call Win32::GUI::Dialog(), the only way to exit is from an
> event.
> This happens when an event handler returns -1. Typically, the
> Terminate
> event handler of your application window should return -1. In
> your case:
>
> sub XX_Terminate {
>      return(-1);
>      }
>
> In other cases, you want to Hide() the window (and return 0) in the
> Terminate event handler instead, so you can Show() it again at a later
> time.
>
>
> /J
>
> -------- ------ ---- --- -- --  --  -    -     -      -         -
> Johan Lindström    Sourcerer @ Boss Casinos     johanl@bahnhof.se
>
> Latest bookmark: "Salon.com Technology  I come to bury IAmCarbona..."
> <http://www.salon.com/tech/feature/2002/08/03/deleteddomains/i
ndex.html>
dmoz (1 of 13): /Computers/Internet/On_the_Web/Weblogs/Tools




-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old cell
phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users


-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users