shadrack has asked for the wisdom of the Perl Monks concerning the following question:
If I run the above code, I never see the "Timer fired" message. However, if I change the SendMessage() call to use WM_CLOSE instead of WM_TIMER, the gui closes (as expected), which I take to be evidence that the theory is sound. I just can't figure out how to get it to work with WM_TIMER or some other message that I can intercept with my own handler.#!perl use threads; use Win32::GUI qw( WM_CLOSE WM_TIMER ); $CHILD = threads->create('child', ''); $WinMain = Win32::GUI::Window->new( -name => 'Main', -text => 'Task Test', -width => 300, -height => 200, -onTerminate => \&Main_Terminate, -onTimer => \&DoTimer, ); $WinMain->Show(); Win32::GUI::Dialog(); $CHILD->detach(); sub Main_Terminate { -1; } sub child { sleep 1; # Give parent time to create window my $parent = Win32::GUI::FindWindow('','Task Test'); Win32::GUI::SendMessage($parent,WM_TIMER,0,0); threads->exit(0); } sub DoTimer { print "Timer fired\n"; return 0; }
Any suggestions?
Oh, and before somebody suggests it, yes I know polling is possible with DoEvents(), however under certain circumstances, DoEvents() can take an indefinite amount of time to return which makes the polling cycle too unpredictable for this particular application.
|
|---|