That worked. Thanks Alan.
Jonathan
At 11/22/2002 10:46 PM, you wrote:
Try playing about with the following (it won't work in version
.665 - and don't ask me how/why it works in .558!). I use it to draw
rectangles for widgets in a primitive but quite useful gui designer
that makes Perl do much of the work we all lo-o-o-ove to do manually.
vPerl it ain't, however! You may want to use $tracker->Hide() to hide
the button until tracking is needed, when $tracker->Show() will "roll
down the blind" and let you follow the mouse pointer around.
$bclass = new Win32::GUI::Class( # reveals _MouseMove events from button
-name => "bclass",
-extends => 'Button',
-widget => "Button",
);
# make an invisible button that covers the area of your graphic
# $x/$y/$w/$h are left/top/width/height of the graphic
$tracker = $mainwin->AddButton (
-name, 'tracker',
-class, 'bclass',
-left, $x,
-top, $y,
-width, $w,
-height, $h,
-pushstyle, 11 | 0x800 , # this makes an invisible button
);
sub tracker_MouseMove {
my($mmx, $mmy) = Win32::GUI::GetCursorPos();
dostuff_with_coordinates();
}
sub tracker->Click {
do_some_stuff();
$tracker->Hide(); # roll it up until it is needed
}
This may also be of some use - I use it as part of a routine that
shifts a desktop planner display back and forth. There is no need for
subclassing, but I don't think it responds to _MouseMove.
# ($left, $top, $width, $height) = dimensions of your graphic object
$clicker = new GUI::Button (
-name, 'clicker',
-parent, $Win,
-left, $left,
-top, $top,
-width, $width,
-height, $height,
-pushstyle, 11,
);
sub clicker_Click {
my($mmx, $mmy) = Win32::GUI::GetCursorPos();
dostuff_with_coordinates();
}
(Aldo, pretty please give us access to the message loop next time
round!)
Virlin