Thanks Jez....... I appreciate your pointers
Although I didn't make a child within the child
what I did was make the main window control the
child.  This seems to work perfectly.  I included
the final test script just in case anyone else
was wondering how this all works.  It's not the
cleanest.....but it does work.....



use Win32::GUI;
use strict;
use warnings;

my $operation = "" ;
my $position  = "" ;

our $child_top    = 0;
our $child_bottom = 0;
our $operation    = "   ";
our $position     = "   ";

&create_main();
&create_child();

our $mainwin->Show();
our $child->Show();
Win32::GUI::Dialog;

#------------------------------------------------------------
sub create_main() {
  $mainwin  =  new Win32::GUI::Window(
                  -name      => "Main",
                  -text      => " OPER = $operation | POS = $position",
                  -top       => 20,
                  -left      => 20,
                  -width     => 225,
                  -height    => 250,
                  -minheight => 235,
                  -minwidth  => 215,
                  -maxheight => 300,
                  -maxwidth  => 250,
                  -vscroll     => 1,
                  );
}
#------------------------------------------------------------
sub create_child() {
  our $top = 10;
  $child = new Win32::GUI::Window (
                  -name        => "Child",
                  -parent      => $mainwin,
                  -height      => 200,
                  -width       => 200,
                  -top         => $child_top,
                  -left        => 0,
                  -popstyle    => WS_CAPTION | WS_SIZEBOX,
                  -pushstyle   => WS_CHILD,
                  -pushexstyle => WS_EX_CLIENTEDGE,
                  );

  for my $x ( 1..25 ) {
    $top = ($x*20) ;
    $child->AddCheckbox(-name =>"test $x",
                  -top  =>$top,
                  -left =>25,
                  -height     =>22,
                  -tabstop=>1,
                  -text =>"test $x",);
    $child->Height($top+30);
  }
  $child_bottom = $top+30;
  my ($width, $height) = ($mainwin->GetClientRect)[2..3];
  $mainwin->ScrollRange(1,0,$child_bottom-$height);
}
#------------------------------------------------------------
sub Main_Scroll() {
  my ($scrollbar, $operation, $position) = @_;
  my ($width, $height) = ($mainwin->GetClientRect)[2..3];
  $mainwin->ScrollRange(1,0,$child_bottom-$height);
  if( ( $operation == 0 ) and ( $child_top <= 0 ) )
                  { # SB_LINEUP
    $mainwin->ScrollPos($scrollbar,$mainwin->ScrollPos($scrollbar) - 1 );
  }
  elsif( ( $operation == 1 ) and ( $child_top > $height - $child_bottom ) )
                        { # SB_LINEDOWN
    $mainwin->ScrollPos($scrollbar,$mainwin->ScrollPos($scrollbar) + 1 );
  }
  elsif( ( $operation == 2 ) and ( $child_top <= 0 ) )
                        { # SB_PAGEUP
    $mainwin->ScrollPos($scrollbar,$mainwin->ScrollPos($scrollbar) - 3 );
  }
  elsif( ( $operation == 3 ) and ( $child_top > $height - $child_bottom ) )
                        { # SB_PAGEDOWN
    $mainwin->ScrollPos($scrollbar,$mainwin->ScrollPos($scrollbar) + 3 );
  }
  elsif( ( $operation == 5 ) and ( ( $child_top <= 0 ) or ( $child_top >
$height - $child_bottom  ) ) )      { # SB_THUMBTRACK
    $mainwin->ScrollPos($scrollbar,$position);
  }

    ($width, $height) = ($mainwin->GetClientRect)[2..3];
    $mainwin->Change(-text=>" OPER = $operation | POS = $position");

  if      ( ( $operation == 0 ) and ( $child_top <= 0 ) )
{ $child_top = $child_top + 1;
  } elsif ( ( $operation == 1 ) and ( $child_top > $height - $child_bottom
) )  { $child_top = $child_top - 1;
  } elsif ( ( $operation == 2 ) and ( $child_top <= 0 ) )
{ $child_top = $child_top + 3;
  } elsif ( ( $operation == 3 ) and ( $child_top > $height - $child_bottom
) )  { $child_top = $child_top - 3;
  } elsif ( $operation == 5 ) { our $child_top = -$position;
  }
  $child->Change(-top=>$child_top);
}
#------------------------------------------------------------

sub Main_Terminate { -1 ; }





                                                                           
                                                                           
                                                                           
                                                                           



Hi,

I can confirm that scrollbars work, and work well.

Your almost there - it took me a while to understand how it all works:)

In windows, scroll bars are really nothing more than dressing and you are
responsible for updating and changing the client area as scrolling takes
place. There are a couple of approaches that can be taken depending on what
needs to be done. In your case, you would have to move all the items up or
down, depending on the scroll bar positions. An alternative approach would
be to create a child window of the child window. This child would contains
all the controls. You then simply move the window up and down as the scroll
bars are moved.

Hopefully this made some sense!

Cheers,

jez.

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <perl-win32-gui-users@lists.sourceforge.net>
Sent: Wednesday, June 16, 2004 9:20 PM
Subject: [perl-win32-gui-users] Window / Dialogbox scrollbars


>
>
>
>
> In the latest WIN32::GUI ver0.0.671 it indicates that the scrollbars have
> been implemented for
> Windows and Dialogbox's.   I cannot seem to figure out how to get the
> client area of the window
> to scroll.  I have some example code below.  Could someone please explain
> to me how I can
> get this to work.  My pea-brain just doesn't seem to grasp what I need to
> do.
> Thanks in advance for any guidance........................
>
>
>  use Win32::GUI;
>  use strict;
>
>  my $operation;
>  my $position;
>
>  our  $mainwin  =  new Win32::GUI::Window(
>     -name      => "Main",
>     -text      => "Main",
>     -top       => 20,
>     -left      => 20,
>     -width     => 250,
>     -height    => 250,
>     -minheight => 235,
>     -minwidth  => 215, );
>
>  our  $child = new Win32::GUI::Window (
>     -name        => "Child",
>     -parent      => $mainwin,
>     -height      => 200,
>     -width       => 200,
>     -top         => 5,
>     -left        => 5,
>     -popstyle    => WS_CAPTION | WS_SIZEBOX,
>     -pushstyle   => WS_CHILD,
>     -pushexstyle => WS_EX_CLIENTEDGE,
>     -vscroll     => 1, );
>
>  $child->AddLabel(      -name =>"OPER",
>                   -top  =>8,
>                   -left =>25,
>                   -text =>"OPER = ",);
>
>  $child->AddLabel(      -name =>"POS",
>                   -top  =>8,
>                   -left =>100,
>                   -text =>"POS = ",);
>
>  $child->AddLabel(      -name =>"SB_OPER",
>                   -top  =>8,
>                   -left =>75,
>                   -text =>" $operation ",);
>
>  $child->AddLabel(      -name =>"SB_POS",
>                   -top  =>8,
>                   -left =>140,
>                   -text =>" $position      ",);
>
>  for my $x ( 1..10 ) {
>    my $top = ($x*25) ;
>    $child->AddCheckbox(-name    =>"test $x",
>                     -top     =>$top,
>                     -left    =>25,
>                     -height  =>22,
>                     -tabstop =>1,
>                     -text    =>"test $x",);
>  }
>
>  $mainwin->Show();
>  $child->Show();
>  Win32::GUI::Dialog;
>
>  sub Child_Scroll() {
>    my ($scrollbar, $operation, $position) = @_;
>    if($operation == 0 )    { # SB_LINEUP
>      $child->ScrollPos($scrollbar,$child->ScrollPos($scrollbar) - 1 );
>    }
>    elsif($operation == 1 ) { # SB_LINEDOWN
>      $child->ScrollPos($scrollbar,$child->ScrollPos($scrollbar) + 1 );
>    }
>    elsif($operation == 2 ) { # SB_PAGEUP
>      $child->ScrollPos($scrollbar,$child->ScrollPos($scrollbar) - 3 );
>    }
>    elsif($operation == 3 ) { # SB_PAGEDOWN
>      $child->ScrollPos($scrollbar,$child->ScrollPos($scrollbar) + 3 );
>    }
>    elsif($operation == 5 ) { # SB_THUMBTRACK
>      $child->ScrollPos($scrollbar,$position);
>    }
>
>    my ($width, $height) = ($child->GetClientRect)[2..3];
>
>    if ( $operation != 8 ) {
>      $child->SB_OPER->Text($operation);
>      $child->SB_POS->Text($position);
> #     print "SCROLLBAR = $scrollbar | OPERATION = $operation | POSITION =
> $position \n";
>    }
>  }
>
>  sub Main_Terminate { -1 ; }
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
> Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
> Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
> REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users






Reply via email to