I think the popstyle and pushstyle are recent additions and they make addstyle 
and co redundant (?) - what version of Win32::GUI are you using?

cheers,

jez.
  ----- Original Message ----- 
  From: Chris Wearn 
  To: 'Jez White' ; 'Win32-GUI' 
  Sent: Wednesday, February 25, 2004 7:40 AM
  Subject: RE: [perl-win32-gui-users] Rebar and toolbar revisited


  Hi All,

   

  I am also very interested in using the Rebar however in the example Jez has 
used below, the window control uses:

   

  -popstyle  => WS_CAPTION | WS_SIZEBOX,
  -pushstyle => WS_CHILD,

   

   If I try to implement the same methods I get an error message informing me 
that I can't use BAREWORDS.

   

  If I change the WS_ constants to their numerical equivalent it appears to 
accept the numeric values, however

  The window won't accept addition or withdrawal of some styles.

   

  Why will it accept WS_ in one instance and only the numerical equivalent in 
another?

   

  Where does -pushstyle fit in with -addstyle?

   

  Is there another equivalent to -popstyle?

   

  Cheers

   

  Chris

   

  -----Original Message-----
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jez White
  Sent: Thursday, 19 February 2004 8:11 PM
  To: Win32-GUI
  Subject: [perl-win32-gui-users] Rebar and toolbar revisited

   

  Hi,

   

  For a while I've been playing with rebars, with the goal of ending up with 
something like the attached image...

   

  With the recent (excellent) additional methods/styles to the toolbar, I went 
back to the rebar, and tried to add a tool bar to it. I couldn't get the 
toolbar to work when it is used by itself - since it requires a parent on 
creation - but I was able to add a toolbar to a child window, which in turn can 
be added to the rebar. This is not ideal, but does work. See the example below 
(I have used some of the new toolbar styles).

   

  Ideally you should be able to add a toolbar, and for that matter a menu 
directly to a rebar control (not via a child window).  I've done some searching 
and came up with the these examples: 

   

  http://www.codeguru.com/toolbar/iebars.html  (the attached image was taken 
from this site, included the C code required to create this example).

  
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_core_rebar_controls_and_bands.asp

  
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_ctoolbar.3a3a.createex.asp

   

  Are these "easy" changes/additions?

   

  Cheers,

   

  jez.

   

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

   

  use Win32::GUI;
  use strict;

   

  #Create the imagelist that will be used for the toolbar
  my $B1 = new Win32::GUI::Bitmap("one.bmp");
  my $B2 = new Win32::GUI::Bitmap("two.bmp");
  my $B3 = new Win32::GUI::Bitmap("three.bmp");
  my $IL = new Win32::GUI::ImageList(16, 16, 0, 3, 10);
  $IL->Add($B1, 0);
  $IL->Add($B2, 0);
  $IL->Add($B3, 0);

   

  #create the main window
  my $mainwindow = new GUI::Window(
      -title    => "Win32::GUI::Rebar test",
      -left     => 100,
      -top      => 100,
      -width    => 600,
      -height   => 200,
      -name     => "Window",
      -onTerminate => sub { return -1 },
  );

   

  #create the child window which will contain the toolbar
  my $band0 = new Win32::GUI::Window (
      -parent    => $mainwindow,
      -name      => "ToolBar",
      -popstyle  => WS_CAPTION | WS_SIZEBOX,
      -pushstyle => WS_CHILD,
  );

   

  #create a child window for band 1 of the rebar control, this band will 
contain two buttons
  my $band1 = new Win32::GUI::Window (
      -parent    => $mainwindow,
      -name      => "Action",
      -popstyle  => WS_CAPTION | WS_SIZEBOX,
      -pushstyle => WS_CHILD,
  );

   

  #Add a button to band 1
  $band1->AddButton (
           -name     => 'Button1',
           -pos      => [0, 1],
           -size     => [60, 20],
           -text     => 'Button 1',
           -tip      => 'Button 1',
           -onClick => sub {print 'Button 1 clicked' },
  );

   

  #Add a button to band 1
  $band1->AddButton (
           -name     => 'Button2',
           -pos      => [65, 1],
           -size     => [60, 20],
           -text     => 'Button 2',
           -tip      => 'Button 2',
           -onClick => sub {print 'Button 2 clicked' },
  );

   

  #create a rebar control
  my $rebar; 
  $rebar = $mainwindow->AddRebar(
      -name   => "Rebar",
      -bandborders => 1,
      #-fixedorder  => 1,
      -onHeightChange => sub {print 'Rebar_HeightChange'.$rebar->Height;},
  );

   

  #Insert band 1
  $rebar->InsertBand (  
    -child     => $band0,
    -width     => 100,
    -minwidth  => 100,
    -minheight => 24,
  );
  #Insert band 2
  $rebar->InsertBand (  
    -child     => $band1,
    -width     => 130,
    -minwidth  => 130,
    -minheight => 24,
  );

   

  #Add the toolbar to band 0
  my $TB = $band0->AddToolbar(
      -name   => "Toolbar",
      -nodivider => 1,
      -onButtonClick => sub {my ($self,$button)[EMAIL PROTECTED];print " button 
$button clicked";},
  );
  #Set the image list, and add the styles 
  $TB->SetImageList($IL);
  
$TB->SetStyle(TBSTYLE_FLAT|TBSTYLE_TRANSPARENT|1|TBSTYLE_LIST|TBSTYLE_TOOLTIPS);
  $TB->SetExtendedStyle(0x00000008);  
  #Add the buttons
  $TB->AddButtons(
      4,
      0, 1, 4, 0, 0,
      1, 2, 4, 0, 1,
      0, 0, 0, TBSTYLE_SEP, 0,
      2, 3, 4, 0, 2,
  );
  #add the tooltips
  $TB->AddString("One");
  $TB->AddString("Two");
  $TB->AddString("Three");

   

  #show the main window
  $mainwindow->Show;

   

  Win32::GUI::Dialog;

   

Reply via email to