Hi all,
Glenn Munroe pointed out that when you return a value from a handler it is
discarded by Win32::GUI. Some notify messages and other messages benefit from
the ability to return a specific result from the wndproc. I've implemented this
as follows: In your handler, if you want to explicitly set the return value,
you must call $win->Result(xxx) where xxx is whatever result you wish to
return. Of course this can also be called as Win32::GUI::Result($handle, xxx).
I chose not to simply take the return value of the handler function because i
feared that that would break almost every Win32::GUI application out there (a
lot of people don't bother with returns at the end of their subroutines).
Example:
return the value 20 from a button click:
my $button = new Win32::GUI::Button($window,
-text => "Hello, world!",
-name => "Button1",
-onClick => \&buttonclicked
);
sub buttonclicked {
my $button = shift;
print "Button was clicked, returning 20\n";
$button->Result(20); # gets sent to windows API.
return 0; # flag for Win32::GUI (as normal).
}
This should work with all event models (with any luck), and I will commit it
thisevening. Also i've made some general tweaks that mean hooks on WM_PAINT and
WM_ERASEBKGND are now called after those messages are processed by Win32::GUI
instead of before. This means that you can hook WM_PAINT on something and paint
whenever you need to paint, which is really handy for drawing things in the
window client area.
Steve