At 08:03 2000-08-27 +0300, [EMAIL PROTECTED] 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 [EMAIL PROTECTED]
Latest bookmark: "Salon.com Technology I come to bury IAmCarbona..."
<http://www.salon.com/tech/feature/2002/08/03/deleteddomains/index.html>
dmoz (1 of 13): /Computers/Internet/On_the_Web/Weblogs/Tools