Hi,

I've been playing with the rebar control. The following code creates a rebar, 
with 3 bands. Band 1 and 3 are empty, with just an text string. Band 2 has a 
child of a window, which contains a datatime control and 2 buttons. Visually, 
everything seems to work. However interacting with the controls in band 2 will 
cause the parent window to lose focus...So is setting the child as a window the 
correct approach?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/rebar/rebar.asp

The example below does not use any bitmaps, so you will just be able to cut, 
paste and run.

Cheers,

jez.

================

use Win32::GUI;
use Win32::GUI::BorderlessWindow;
use strict;
 
#create a dummy menu
my $Menu = new Win32::GUI::Menu(
    "&File" => "File",
    "   >   &New",
    "   >   &Open",
    "   >   &Save",
    "   >   Save &As",
    "   >   &Close",

    "&Edit" => "Edit",
    "   >   &Undo",
    "    >    -" => 0,
    "   >   Cu&t",
    "   >   &Copy",
    "   >   &Paste" ,

    "&Program" => "Program",
    "   >   &View Structure",
    "   >   &Rebuild Structure",

    "&Run" => "Run",
    "   >   &Execute",
    "   >   &Debug" ,

);

my $win = new Win32::GUI::BorderlessWindow(
    -title    => "",
    -left     => 0,
    -top      => 0,
    -width    => 100,
    -height   => 50,
    -name     => "Test",
);

# Date time control
my $DateTime = $win->AddDateTime (
    -name     => "DateTime",
    -pos      => [0, 0],
    -size     => [130, 20],
    -tip      => 'A date and time',
);

$DateTime->Format('dd-MMM-yyyy HH:mm:ss');

my $but = $win->AddButton (
         -name     => "Button",
         -pos      => [135, 0],
         -size     => [50, 20],
         -text     => 'Button',
         -tip      => 'A Button',
         -events   =>{
   Click => sub {print 'button clicked' },
          }
);
my $but1 = $win->AddButton (
         -name     => "Button1",
         -pos      => [195, 0],
         -size     => [50, 20],
         -text     => 'Button1',
         -tip      => 'A Button',
         -events   =>{
   Click => sub {print 'button 1 clicked' },
          }
);

my $W = new GUI::Window(
    -title    => "Win32::GUI::Rebar test",
    -left     => 100,
    -top      => 100,
    -width    => 400,
    -height   => 200,
    -name     => "Window",
    -menu   => $Menu,
    -events   =>{
      Terminate => sub { return -1 },
  }
);
  
#create a rebar control
 
my $rebar = $W->AddRebar(
    -name   => "Rebar",
    -bandborders => 1,
    -varheight => 0,
  #  -imagelist => $IL,
);

$rebar->InsertBand (-text => 'One' ,);

$rebar->InsertBand (-text => '',
  -child => $win ,
  -width => 250,
  -minwidth => 250,
  -minheight => 20,
);

$rebar->InsertBand (-text => 'Two' ,);
 
$W->Show;
 
Win32::GUI::Dialog;


Reply via email to