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

>    1. MouseMove (Jonathan Southwick)
> Message: 1
> Date: Fri, 22 Nov 2002 13:07:22 -0500
> To: perl-win32-gui-users@lists.sourceforge.net
> From: Jonathan Southwick <[EMAIL PROTECTED]>
> Subject: [perl-win32-gui-users] MouseMove


> I want to be able to track the mouse over a Graphic object.  I tried to 
> follow the general outline of the mousemove.pl sample included with the 
> WIn32 module but I can't get it to work properly.

> Has anyone been able to accomplish this?


> Jonathan


Reply via email to