Ok - this is the code I've got (run in the samples folder to pick up the 
bitmap). I've hooked the WM_ERASEBKGND for one of the child controls, and I 
think I'm calling the WM_ERASEBKGND for the parent window - still no joy - the 
background is not correct - am I missing something simple?

Cheers,

jez.

- any suggestions?

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",
    #-class    => $WC,
    -onTerminate => sub { return -1 },
);

#$mainwindow->Hook(20,\&OtherErase);
#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|WS_CLIPCHILDREN,
    #-pushexstyle => WS_EX_TRANSPARENT,
);

#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|WS_CLIPCHILDREN,
    #-pushexstyle => WS_EX_TRANSPARENT,
);
$band1->Hook(20,\&EraseTest);
#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,
  -bitmap    => $B1
);
#Insert band 2
$rebar->InsertBand (  
  -child     => $band1,
  -width     => 130,
  -minwidth  => 130,
  -minheight => 24,
  -bitmap    => $B1
);

#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;


sub EraseTest {
  #send the WM_ERASEBKGND to the main window.
  print 'in Erase';
  #$mainwindow->InvalidateRect(1);
  
  my $dchandle= $mainwindow->GetDC->{-handle};
  Win32::GUI::SendMessage($mainwindow, 20, $dchandle, 0);
  return 1;
}

#sub OtherErase {
#  print 'in other';
#  return 1;
#}



  ----- Original Message ----- 
  From: Jez White 
  To: Win32-GUI ; Steve Pick 
  Sent: Monday, February 23, 2004 11:26 AM
  Subject: Re: [perl-win32-gui-users] Hook and WM_ERASEBKGND


  Arh! The problem (from msdn):

  "Normally, if you wanted the dialog bar band to appear transparent, you would 
set the WM_EX_TRANSPARENT extended style for the dialog bar object. However, 
because WM_EX_TRANSPARENT has some issues with properly painting the background 
of a dialog bar, you will need to do a little extra work to achieve the desired 
effect"

  What this means is when you attach a child window (dialog bar) to a rebar 
control, the background is not drawn correctly if you use anything in the 
background (a color or bitmap) - under XP (using XP styles), the problem 
becomes more apparent since the rebar is drawn with the current style.

  A solution is to this problem is presented in the following links:

  
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/vcconusingdialogbarwithrebarcontrol.asp
  http://www.funducode.com/freevc/toolbar/toolbar3.asp

  However, both of these solutions require you to handle the WM_ERASEBKGND 
message and pass it to the parent control - is this kind of thing you can do 
with Hook?

  Cheers,

  jez.
    ----- Original Message ----- 
    From: Jez White 
    To: Win32-GUI ; Steve Pick 
    Sent: Monday, February 23, 2004 11:16 AM
    Subject: [perl-win32-gui-users] Hook and WM_ERASEBKGND


    Steve,

    I'm still playing with rebars, and have come across an interesting 
problem:) To quote from msdn:


Reply via email to