Ok - I've "fixed" the problem - but before I commit it - do you think this was
a real bug?
Cheers,
jez.
----- Original Message -----
From: Jez White
To: Win32-GUI
Sent: Monday, February 07, 2005 2:53 PM
Subject: [perl-win32-gui-users] A bug with Hook?
Hi,
I've just spent ages tracking down a problem in my code...it turns out that
it was a simple typo - I spelt a method name incorrectly:) The program should
have died, but it didn't - this is due to hook not propagating die.
The example below shows the bug in action - a timer sends a message to a
window, which is then picked up by hook. As you can see, the programme should
die but it continues on it's merry way.
Before I spend some time trying to fix this problem am I correct in assuming
this is a bug?
Cheers,
jez.
---------------------------------
#!/usr/local/bin/perl -w
$|++;
use strict;
use Win32::GUI;
my $winTimer = Win32::GUI::Window->new(
-name => "winTimer",
-left => 50,
-top => 50,
-height => 200,
-width => 300,
-text => "test",
);
#hook the message
$winTimer->Hook(0x8000+3,\&Message);
#add a timer handler
$winTimer->SetEvent('Timer',\&Timer);
#create a timer
my $timTimer = $winTimer->AddTimer("timTimer", 100);
$winTimer->Show();
Win32::GUI::Dialog();
sub Message {
print shift;
die 'some problem';
print 'do we get here?';
}
sub Timer {
#send a message to the window which is picked up by the hooked message
handler.
$winTimer->SendMessage(0x8000+3,0,0);
}