Good timing.  I just went through getting that to work.  This code
fragment might help you, it's straight from my app.  Your mileage (and
options and variables and etc) may vary.  This isn't a complete app
obviously, but I think this is all that's relevant to wheel scrolling.
The $dy global is how much to scroll on each well detente, and
$lastscrollpos is a global for holding the last position.  I hope the
rest is self-explanatory.  Season to taste.

use Win32::GUI qw(WM_MOUSEWHEEL);
my $scrollapi = new Win32::API('user32', 'ScrollWindow', ['N', 'I', 'I',
'P', 'P'], 'N') or die "Can't load ScrollWindow API";

my $main = Win32::GUI::Window->new(-name => "Main"
                                   , -text => "Main Window"
                                   , -size => [$main_w, $main_h]
                                   , -hasmaximize => 0
                                   , -dialogui => 1
                                   , -onTerminate => \&terminatemain);

$main->Hook(WM_MOUSEWHEEL, \&domousewheel);
$main->Show();

my $scrollwindow = Win32::GUI::Window->new(-name =>"scrollwindow"
                                           , -parent => $main
                                           , -pos => [$sw_x, $sw_y]
                                           , -size => [$sw_h, $sw_w]
                                           , -dialogui => 1
                                           , -tabstop => 1
                                           , -vscroll => 1
                                           , -titlebar => 0
                                           , -sizeable => 0
                                           , -controlparent => 1
                                           , -pushstyle => WS_CHILD
                                           , -pushstyle => WS_VSCROLL
                                           , -popstyle => WS_THICKFRAME
                                           , -onScroll => \&doscroll);

$scrollwindow->Hook(WM_MOUSEWHEEL, \&domousewheel);
$scrollwindow->Show();

# create whatever controls or subwindows go inside the scrolling area
here, as children of $scrollwindow

sub domousewheel {
  my ($object, $wParam, $lParam, $type, $msgcode) = @_;
  my $distance = makesignedshort(($wParam & 0xFFFF0000) >> 16);
  my $buttons = makesignedshort($wParam & 0x0000FFFF);
  my $y =makesignedshort(($lParam & 0xFFFF0000) >> 16);
  my $x = makesignedshort($lParam & 0x0000FFFF);
  my $isdropped = $object->SendMessage(CB_GETDROPPEDSTATE, 0, 0);
  return 1 if $isdropped;
  if (0 < $distance) {
    scrollmebro(-(2*$dy), 0);
  } elsif (0 > $distance) {
    scrollmebro(2*$dy, 0);
  }
  return 0;
}

sub scrollmebro {
  my ($offset, $newpos) = @_;
  my $curpos = $scrollwindow->ScrollPos(SB_VERT);
  my ($min, $max) = $scrollwindow->ScrollRange(SB_VERT);
  my $pos;
  if ($offset) {
    $pos = $curpos + $offset;
  } elsif ($newpos) {
    $pos = $newpos;
  }
  if (defined $pos) {
    $pos = 0 if 0 > $pos;
    $pos = $max if $max < $pos;
    $scrollwindow->ScrollPos(SB_VERT, $pos);
    my $deltapos = $lastscrollpos - $pos;
    $scrollapi->Call($scrollwindow->{-handle}, 0, $deltapos, 0, 0);
    $lastscrollpos = $pos;
  }
}


Waldemar Biernacki wrote:
> Hey everybode!
>
> Do you know whether mouse scrolling button is implemented in Win32::GUI and 
> how? 
>
>
> Waldemar
>
>
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
>   

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Reply via email to