RE: [perl-win32-gui-users] working/not working timer

2005-08-04 Thread Jeremy White

In this script timer not works. I know because event handler was never
executed (no output to console). But when I remove onTerminate
parameter when creating main window and use old event model
(mw_Terminate sub) then timer starts to work! Isn't it the bug?


No - I dont think so - try this:

use strict;
use Win32::GUI;


my $mw = Win32::GUI::Window->new(-name => 'mw',
-size => [400, 400],
-pos => [200, 200],
-title => "FormsTest",
-onTerminate => sub{return -1;},
-onTimer => \&T1_Timer,
);


my $t1 = Win32::GUI::Timer->new($mw, 'T1', 2000);

$mw->Show;
Win32::GUI::Dialog;

sub T1_Timer {
local $| = 1;
print "Handler starts";
my $flag = $mw->IsVisible();
if ($flag) {
$mw->Hide();
}
else {
$mw->Show();
}
print "Handler ends";
return 1;
}





Re[2]: [perl-win32-gui-users] working/not working timer

2005-08-04 Thread Сергей Черниенко
Здравствуйте Jeremy,

Thursday, August 04, 2005, 3:38:52 PM, Вы написали:


>>In this script timer not works. I know because event handler was never
>>executed (no output to console). But when I remove onTerminate
>>parameter when creating main window and use old event model
>>(mw_Terminate sub) then timer starts to work! Isn't it the bug?

JW> No - I dont think so - try this:

Yes, it works. But what if I need 2 timers? And does it mean that OEM
and NEM can not be mixed?

JW> use strict;
JW> use Win32::GUI;


JW> my $mw = Win32::GUI::Window->new(-name => 'mw',
-size => [400, 400],
-pos => [200, 200],
-title => "FormsTest",
-onTerminate => sub{return -1;},
-onTimer => \&T1_Timer,
JW> );


JW> my $t1 = Win32::GUI::Timer->new($mw, 'T1', 2000);

$mw->>Show;
JW> Win32::GUI::Dialog;

JW> sub T1_Timer {
JW> local $| = 1;
JW> print "Handler starts";
my $flag = $mw->>IsVisible();
JW> if ($flag) {
$mw->>Hide();
JW> }
JW> else {
$mw->>Show();
JW> }
JW> print "Handler ends";
JW> return 1;
JW> }



-- 
С уважением,
 Сергейmailto:[EMAIL PROTECTED]





RE: Re[2]: [perl-win32-gui-users] working/not working timer

2005-08-04 Thread Jeremy White

Yes, it works. But what if I need 2 timers? And does it mean that OEM
and NEM can not be mixed?


The event handler receives two parameters, the first is the window, the 
second is the name of the timer. See code below to see how this works. As 
for OEM/NEM - you can mix them sometimes, but I wouldn't recommend doing it. 
Out of the two, NEM is much more flexible - and faster too.


Cheers,

jez.

use strict;
use Win32::GUI;


my $mw = Win32::GUI::Window->new(-name => 'mw',
-size => [400, 400],
-pos => [200, 200],
-title => "FormsTest",
-onTerminate => sub{return -1;},
-onTimer => \&T1_Timer,
);


my $t1 = Win32::GUI::Timer->new($mw, 'T1', 2000);
my $t2 = Win32::GUI::Timer->new($mw, 'T2', 500);

$mw->Show;
Win32::GUI::Dialog;

sub T1_Timer {
my ($win,$timer)[EMAIL PROTECTED];
if ($timer eq 'T1') {
 local $| = 1;
 print "Handler starts";
 my $flag = $mw->IsVisible();
 if ($flag) {
 $mw->Hide();
 }
 else {
 $mw->Show();
 }
 print "Handler ends";
}
if ($timer eq 'T2') {
 print "T2 timer\n";
}
return 1;
}





RE: Re[2]: [perl-win32-gui-users] working/not working timer

2005-08-04 Thread Lloyd, Steve
Can you explain how the -ontimer option works?
-onTimer => \&T1_Timer,

Using -ontimer, how do you set how often it kicks off?

Steve

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Jeremy White
Sent: Thursday, August 04, 2005 8:02 AM
To: [EMAIL PROTECTED]; perl-win32-gui-users@lists.sourceforge.net
Subject: RE: Re[2]: [perl-win32-gui-users] working/not working timer



>Yes, it works. But what if I need 2 timers? And does it mean that OEM 
>and NEM can not be mixed?

The event handler receives two parameters, the first is the window, the 
second is the name of the timer. See code below to see how this works.
As 
for OEM/NEM - you can mix them sometimes, but I wouldn't recommend doing
it. 
Out of the two, NEM is much more flexible - and faster too.

Cheers,

jez.

use strict;
use Win32::GUI;


my $mw = Win32::GUI::Window->new(-name => 'mw',
-size => [400, 400],
-pos => [200, 200],
-title => "FormsTest",
-onTerminate => sub{return -1;},
-onTimer => \&T1_Timer,
);


my $t1 = Win32::GUI::Timer->new($mw, 'T1', 2000);
my $t2 = Win32::GUI::Timer->new($mw, 'T2', 500);

$mw->Show;
Win32::GUI::Dialog;

sub T1_Timer {
my ($win,$timer)[EMAIL PROTECTED];
if ($timer eq 'T1') {
  local $| = 1;
  print "Handler starts";
  my $flag = $mw->IsVisible();
  if ($flag) {
  $mw->Hide();
  }
  else {
  $mw->Show();
  }
  print "Handler ends";
}
if ($timer eq 'T2') {
  print "T2 timer\n";
}
return 1;
}




---
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle
Practices Agile & Plan-Driven Development * Managing Projects & Teams *
Testing & QA Security * Process Improvement & Measurement *
http://www.sqe.com/bsce5sf
___
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users

This email, and any files previous email messages included with it, may contain 
confidential and/or privileged material. If you are not the intended recipient 
please contact the sender and delete all copies.





RE: Re[2]: [perl-win32-gui-users] working/not working timer

2005-08-04 Thread Jeremy White

Can you explain how the -ontimer option works?
-onTimer => \&T1_Timer,


The onTime is the event handler for all timers for a specific window. In the 
example below, we're adding 4 timers to the window. When the timer is fired, 
it's name is printed out. Does that help?


Cheers,

jez.

use strict;
use Win32::GUI;

my $mw = Win32::GUI::Window->new(
 -name => 'mw',
 -size => [400, 400],
 -pos => [200, 200],
 -onTerminate => sub{return -1;},
 -onTimer => sub{print $_[1]."\n"},
);
$mw->AddTimer('Slow', 2000);
$mw->AddTimer('Medium', 1000);
$mw->AddTimer('Quick', 500);
$mw->AddTimer('Very Quick', 250);
$mw->Show;
Win32::GUI::Dialog;





RE: Re[2]: [perl-win32-gui-users] working/not working timer

2005-08-04 Thread Lloyd, Steve
Yes it does.  So, I guess I do not see its usefulness. 
In your example the same sub would be kicked off multiple times at the
same time, right?
How is this useful?

MillisecondsTimer Runs
250 once
500 twice
750 once
1000three times
2000four times

-Original Message-
From: Jeremy White [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 04, 2005 10:30 AM
To: Lloyd, Steve; [EMAIL PROTECTED];
perl-win32-gui-users@lists.sourceforge.net
Subject: RE: Re[2]: [perl-win32-gui-users] working/not working timer



>Can you explain how the -ontimer option works?
>-onTimer => \&T1_Timer,

The onTime is the event handler for all timers for a specific window. In
the 
example below, we're adding 4 timers to the window. When the timer is
fired, 
it's name is printed out. Does that help?

Cheers,

jez.

use strict;
use Win32::GUI;

my $mw = Win32::GUI::Window->new(
  -name => 'mw',
  -size => [400, 400],
  -pos => [200, 200],
  -onTerminate => sub{return -1;},
  -onTimer => sub{print $_[1]."\n"},
);
$mw->AddTimer('Slow', 2000);
$mw->AddTimer('Medium', 1000);
$mw->AddTimer('Quick', 500);
$mw->AddTimer('Very Quick', 250);
$mw->Show;
Win32::GUI::Dialog;



This email, and any files previous email messages included with it, may contain 
confidential and/or privileged material. If you are not the intended recipient 
please contact the sender and delete all copies.





RE: Re[2]: [perl-win32-gui-users] working/not working timer

2005-08-04 Thread Lloyd, Steve
In answer to my own question, I guess you could base what the sub did on
the timer name.
So you could set one timer per day, hour, and minute that did different
things based on the name of the timer..



use strict;
use Win32::GUI;

my $mw = Win32::GUI::Window->new(
  -name => 'mw',
  -size => [400, 400],
  -pos => [200, 200],
  -onTerminate => sub{return -1;},
  -onTimer => sub{my $name=$_[1];MyTimers($name);},
);
$mw->AddTimer('Slow', 2000);
$mw->AddTimer('Medium', 1000);
$mw->AddTimer('Quick', 500);
$mw->AddTimer('Very Quick', 250);
$mw->Show;
Win32::GUI::Dialog;

sub MyTimers{
my $timer=shift;
if($timer=~/^slow$/is){
print "running slow stuff\n";
}
elsif($timer=~/^medium$/is){
print "running medium stuff\n";
}
elsif($timer=~/^quick$/is){
print "running quick stuff\n";
}
elsif($timer=~/^very quick$/is){
print "running very quick stuff\n";
}
}

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Lloyd, Steve
Sent: Thursday, August 04, 2005 10:38 AM
To: Jeremy White; [EMAIL PROTECTED];
perl-win32-gui-users@lists.sourceforge.net
Subject: RE: Re[2]: [perl-win32-gui-users] working/not working timer


Yes it does.  So, I guess I do not see its usefulness. 
In your example the same sub would be kicked off multiple times at the
same time, right? How is this useful?

MillisecondsTimer Runs
250 once
500 twice
750 once
1000three times
2000four times

-Original Message-
From: Jeremy White [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 04, 2005 10:30 AM
To: Lloyd, Steve; [EMAIL PROTECTED];
perl-win32-gui-users@lists.sourceforge.net
Subject: RE: Re[2]: [perl-win32-gui-users] working/not working timer



>Can you explain how the -ontimer option works?
>-onTimer => \&T1_Timer,

The onTime is the event handler for all timers for a specific window. In
the 
example below, we're adding 4 timers to the window. When the timer is
fired, 
it's name is printed out. Does that help?

Cheers,

jez.

use strict;
use Win32::GUI;

my $mw = Win32::GUI::Window->new(
  -name => 'mw',
  -size => [400, 400],
  -pos => [200, 200],
  -onTerminate => sub{return -1;},
  -onTimer => sub{print $_[1]."\n"},
);
$mw->AddTimer('Slow', 2000);
$mw->AddTimer('Medium', 1000);
$mw->AddTimer('Quick', 500);
$mw->AddTimer('Very Quick', 250);
$mw->Show;
Win32::GUI::Dialog;



This email, and any files previous email messages included with it, may
contain confidential and/or privileged material. If you are not the
intended recipient please contact the sender and delete all copies.




---
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle
Practices Agile & Plan-Driven Development * Managing Projects & Teams *
Testing & QA Security * Process Improvement & Measurement *
http://www.sqe.com/bsce5sf
___
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users



[perl-win32-gui-users] Mixing OEM and NEM events [Was: working/not working timer]

2005-08-04 Thread Robert May

Сергей Черниенко wrote:
[ snipped timer-related stuff ]

And does it mean that OEM
and NEM can not be mixed?


By default a window/control uses the Original/Old Event Model (OEM), 
where the sub that is called is the -name of the window/control followed 
by '_' followed by the event name itself. (So for a control with -name 
=> 'ABC', the click event sub is ABC_Click.  This sub must be located in 
package main (the default package).


As soon as any New Event Model (NEM) option is given to the constructor, 
Win32::GUI turns off all OEM subroutine calls.  Using NEM allows us to 
use any sub name we want, from any package.  We can event use anonymous 
subs.


If you really want to have both OEM and NEM callbacks existing at the 
same time, then you can pass -eventmodel => 'both' to the 
window/control's constructor (other allowed values are 'byname' to force 
OEM, and 'byref' to force NEM).  If you have both event models enabled, 
then currently the NEM sub gets called first (but don't rely on this 
behaviour)


Personally I find it very confusing having both enabled, and I would 
consider it 'best practice' to use one or the other.  The NEM is far 
more powerful (and essential if you want to put different bits of your 
UI code into different packages), but I can see how anyone coming from 
VB would find the OEM more understandable.


Hope this s useful.

Rob.



[perl-win32-gui-users] MouseOver and MouseOut Events [Was: The window -backgroud option]

2005-08-04 Thread Robert May

Lloyd, Steve wrote:

Rob,
Is there a planned date for the next release?


Not really.  Perhaps the end of the month would be a good target, but I 
have some travel, so may not get to do a whole lot more between now and 
then - lets see how things go.



Also, many of the common events do not work on the main Window, right?


Not that I'm aware of, but I haven't really looked.


Like MouseOver and MouseOut...


These I have looked at (some time ago) and there's a whole load of 
jiggery-pokery that surrounds these 2 events and getting them to fire 
for any window/control.  Look on MSDN for WM_MOUSEHOVER, WM_MOUSELEAVE 
and TrackMouseEvent().


Rob.



Re: [perl-win32-gui-users] Mixing OEM and NEM events [Was: working/not working timer]

2005-08-04 Thread Ariel Serbin
While I'm an avid user fo Win32::GUI, I don't know
much about the internals... That being said, it does
seem more intuitive to be able to assign callbacks to
specific timers (as opposed to setting up a switch
type dispatcher based on the timer name.)  Basically,
it would be like having an -onclick type property for
the timer...

-Ariel

--- Robert May <[EMAIL PROTECTED]> wrote:

> Ñåðãåé ×åðíèåíêî wrote:
> [ snipped timer-related stuff ]
> > And does it mean that OEM
> > and NEM can not be mixed?
> 
> By default a window/control uses the Original/Old
> Event Model (OEM), 
> where the sub that is called is the -name of the
> window/control followed 
> by '_' followed by the event name itself. (So for a
> control with -name 
> => 'ABC', the click event sub is ABC_Click.  This
> sub must be located in 
> package main (the default package).
> 
> As soon as any New Event Model (NEM) option is given
> to the constructor, 
> Win32::GUI turns off all OEM subroutine calls. 
> Using NEM allows us to 
> use any sub name we want, from any package.  We can
> event use anonymous 
> subs.
> 
> If you really want to have both OEM and NEM
> callbacks existing at the 
> same time, then you can pass -eventmodel => 'both'
> to the 
> window/control's constructor (other allowed values
> are 'byname' to force 
> OEM, and 'byref' to force NEM).  If you have both
> event models enabled, 
> then currently the NEM sub gets called first (but
> don't rely on this 
> behaviour)
> 
> Personally I find it very confusing having both
> enabled, and I would 
> consider it 'best practice' to use one or the other.
>  The NEM is far 
> more powerful (and essential if you want to put
> different bits of your 
> UI code into different packages), but I can see how
> anyone coming from 
> VB would find the OEM more understandable.
> 
> Hope this s useful.
> 
> Rob.
> 
> 
>
---
> SF.Net email is Sponsored by the Better Software
> Conference & EXPO
> September 19-22, 2005 * San Francisco, CA *
> Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects
> & Teams * Testing & QA
> Security * Process Improvement & Measurement *
> http://www.sqe.com/bsce5sf
> ___
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
>
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
>