Plum, Jason wrote:
Could someone provide me with some insight as to the requirements to make use of TrackMouse and such functions as MouseOver on a window? I must be missing something simple because I can’t get them to work.

Does this help? You can only usefully call TrackMouse() when you're already over a window - if you call it when out of a window it will either do nothing, or if you pass TME_LEAVE flag you'll get an immediate MouseOut event.

When over a window the TME_HOVER flag results in a MouseOver event, after the mouse is stationary for the timeout peiod (default is 400ms I think), and TME_LEAVE flag results in a MouseOut event when the mouse leaves the window.

There appears to be some code in GUI_MessageLoops.cpp that attempts to reset things when the MouseOut and MOUSEIn events happen, but as written it doesn't do anything.

Rob.

#!perl -w
use strict;
use warnings;

use Win32::GUI();

sub TME_HOVER() {1}
sub TME_LEAVE() {2}
sub HOVER_DEFAULT() {0xFFFFFFFF}

my $state = 0; # 0 - out; 1 - in;

my $mw = Win32::GUI::Window->new(
        -title => "MouseOver/Out",
        -pos => [100,100],
        -size => [400,300],
        -onMouseOver => sub {print "Hover\n"; return 0;},
        -onMouseOut  => sub {print "Out\n"; $state=0; return 0;},
        -onMouseMove => \&Move,
);

$mw->Show();
Win32::GUI::Dialog();
exit(0);

sub Move
{
        return unless $state == 0;
        print "In\n";
        $state = 1;
        $mw->TrackMouse(1000,TME_HOVER|TME_LEAVE);
        return 1;
}
__END__

--
Robert May
Win32::GUI, a perl extension for native Win32 applications
http://perl-win32-gui.sourceforge.net/

Reply via email to