Hi Rob,

Thanks for the explanation.  Now that you mentioned it I recall reading
somewhere OEM versus NEM.  Guess I forgot about that.  Thats what I get for
using old code without deeper reading.

Thanks again.
Brian


On 7/31/07, Robert May <[EMAIL PROTECTED]> wrote:
>
> On 31/07/07, Brian Fredette <[EMAIL PROTECTED]> wrote:
> > I found the threads example posted in this group and began playing
> around.
> > I've modified the code to add a splash screen using
> Win32::GUI:SplashScreen,
> > a timer taken from Tutorial_Part4_timer.pl, a statusbar, and a
> notifyicon.
> > For some reason the timer never gets fired.  I've tried removing the
> > splashscreen and threads but it still won't fire.  The tutorial works
> ...
> > why doesn't this:
>
> If you've already gone to the trouble of removing the SplashScreen
> code and the threads code and seen that the problem still exists, why
> not post that short code, rather than making us wade through lots of
> unnecessary stuff?
>
> [snip very long code]
>
> I can reduce your problem to this:
>
> #!/perl -w
> use strict;
> use warnings;
>
> use Win32::GUI();
>
> my $win = new Win32::GUI::Window(
>    -name     => 'winMain',
>    -size     => [700, 500],
>    -onResize => \&resizeWin,
> );
> $win->AddTimer('T1', 1000);
>
> $win->Show();
> Win32::GUI::Dialog();
>
> sub resizeWin {
>    print "Resize Event seen\n";
> }
>
> sub T1_Timer {
> print "Timer went off!\n";
> }
>
> and it stems from the fact that you are mixing the 'Old Event Model'
> (OEM) with the 'New Event Model' (NEM).
>
> The Old Event Model is the one that calls subs by a name composed of
> the name of the object and the name of the event (e.g. in your example
> T1_Timer())
>
> The New Event Model is the one that calls a sub that you specify using
> a -onXXX option to the constructor (e.g. in your example -onResize =>
> \&resizeWin)
>
> For (I think) performance reasons, when you specify a NEM event
> handler using an -onXXX option in the constructor, then the OEM method
> of working is switched off - hence in your example the T1_Timer() sub
> is never called (btw in your example the _Maximize, _Minimize, _Resize
> and _Terminate handlers are never called either)
>
> There are 3 ways to fix this.
>
> (1) Only use OEM event handlers: remove the -onResize option, and
> rename resizeWin() as winMain_Resize() (you'll need to remove the
> winMain_Resize you already have defined)
>
> (2) Use only NEM event handlers: add an -onTimer =>
> \&some_timer_hander line to the main window constructor, and rename
> the T1_Timer() sub some_timer_handler()
>
> (3) Leave it all as it is, and add an -eventmodel => 'both' line to
> the main window constructor.   This is not the preferred solution, as
> it is very easy to get confused and have 2 handlers for the same event
> - for example if you did this to your code, you would have 2 handlers
> for the Resize event (resizeWin() and winMain_Resize()) - as it
> happens, the NEM handler would get called first, and because it
> doesn't return 0, the OEM handler would get called afterwards.   If
> the NEM handler returned 0, the OEM handler wouldn't get called ...
> see how this gets confusing ...
>
> Regards,
> Rob.
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Reply via email to