Your code is bad. What you're doing is creating a floating "BorderlessWindow" positioned over the top of the main window. If you want to put your window *INSIDE* the client area I suggest you do this:
 
use Win32::API;
our $SETPARENT = new Win32::API("user32","SetParent","NN","N") or croak "Failed to load SetParent from user32.dll";
 
my $child = new Win32::GUI::DialogBox(
    -parent => $win,
    -name => "Child",
    -left => 0,
    -top => 0,
    -text => "Child",
    -width => 100,
    -height => 100,
    -style => WS_CHILD,
   );
 
$SETPARENT->Call($child->{-handle}, $win->{-handle});
$child->Width($child->Width); # force update.
 
After doing this stuff, you'll find you have a dialogbox inside the main window. It also clips if you drag it "out" of the main window, so it truely is inside. You can even give it a WS_CAPTION and drag it around in the client area.
 
Giving things a -parent argument does NOT mean SetParent is called on them in Win32::GUI.
 
Steve
 
 
-----Original Message-----
From: perl-win32-gui-users-admin@lists.sourceforge.net [mailto:perl-win32-gui-users-admin@lists.sourceforge.net]On Behalf Of Jez White
Sent: 16 January 2004 12:37
To: Win32-GUI
Subject: [perl-win32-gui-users] Scroll bar example

Hi,
 
The example below will only work on the latest code line from CVS.
 
I'm trying to get my head round using scroll bars. In my test example I want to create a window containing one tab strip. In the tab strip there will be a child window containing a scroll bar and 10 buttons. Scrolling the scroll bar will move the buttons into and out view.
 
Now, the scrolling part works fine - but is using a child window in this way the correct approach? For example, interacting with the child window (clicking on a button, or scrolling) loses focus (which you would expect for a normal window) but is not the correct behaviour in this case. Am I missing something fundamental?
 
Apologies for the dodgy code - is a hack job:)
 
cheers,
 
jez.
 
===========
use Win32::GUI;
use Win32::GUI::BorderlessWindow;
 
#create the main window
my $win = new Win32::GUI::Window (
 -name => "MainWin",
 -left => 0,
 -top => 100,
 -width => 500,
 -height => 300,
 -sizable => 1,
 -text => "Scrollbar Test 2",
 -noflicker => 1,
);
 
#create a tab strip
$win->AddTabStrip (
 -name => "Tab",
 -left => 0,
 -top => 100,
 -width => 250,
 -height => 150, 
);
$win->Tab->InsertItem(-text => 'Some Tab');
 
#create a child window with a scroll bar
my $childwin = new Win32::GUI::BorderlessWindow (
 -name => "Child",
 -parent =>$win,
 -left => 10,
 -top => 250,
 -width => 200,
 -height => 120,
 -hscroll => 1,
 -noflicker => 1,
 -onScroll => \&scrolled
);
 
#create content for our child window, 10 buttons.
foreach (0..9) {
  $childwin->AddButton (
           -name     => "Button".$_,
           -pos      => [$_*50, 30],
           -size     => [50, 20],
           -text     => 'Button'.$_,);
}
 
#set the scrollbar range and starting pos
$childwin->ScrollRange(0,0,450);
$childwin->ScrollPos(0,0);
 
$win->Show;
$childwin->Show;
Win32::GUI::Dialog;
 
sub scrolled {
 my($object,$bar,$operation,$pos) = @_;
 my $string;
 $object->Scroll($bar,$operation,$pos);
 #Scroll the buttons...
 if($operation == SB_THUMBTRACK) {
    foreach (0..9) {
      $string='Button'.$_;
      $childwin->$string->Move(($_*50)-$pos,30);
    }
  }
}