I have been playing around with samples/BitmapScroll.pl from the
Win32-GUI-1.0 source using perl 5.6 on WinXP SP2.  I can't seem to get
a Brush or Pen working for me.  No matter what I do (so far), the
rectangle is drawn with the brush/pen I think I'm specifying.  The
majority of this code is straight from the BtimapScroll.pl sample.

use Win32::GUI;
use strict;


#create a new class which stops the WM_ERASEBKGND message from erasing
the background
#this stops the flicker of the window on resize.
my $WC = new Win32::GUI::Class(
    -name => "NoFlicker", 
    -style => 0,
);

#Create the window and child controls.
my $mainwin = new Win32::GUI::Window (
    -pos         => [100, 100],
    -size        => [330, 235],
    -name        => "Window",
    -text        => "Bitmap Scroll demo",
    -pushstyle   => WS_CLIPCHILDREN,
    -class       => $WC,
    #NEM Events for this window
    -onResize    => \&MainResize,
    -onTerminate => sub {return -1;}
);

$mainwin->AddButton (
    -name        => 'Open',
    -pos         => [205, 20],
    -size        => [110, 20],
    -text        => 'Open Bitmap',
    -onClick     => \&FindAndOpenBitmap,
);

#Define global variables
my $memdc;
my $bitmap;        #will hold the bitmap
###############################
#   my brush and pen objects
our $dragpen = Win32::GUI::Pen->new(-color=>[0,255,0],-width=>5);
our $dragbrush = Win32::GUI::Brush->new(-color=>[0,0,255]);
###############################

#Create a child window with a scroll bars. 
my $ChildWin = new Win32::GUI::Window (
    -parent      => $mainwin,
    -name        => "ChildWin",
    -pos         => [0, 0],
    -size        => [200, 200],
    -popstyle    => WS_CAPTION | WS_SIZEBOX,
    -pushstyle   => WS_CHILD | WS_CLIPCHILDREN,
    -pushexstyle => WS_EX_CLIENTEDGE,
    -class       => $WC,
    -hscroll     => 1,
    -vscroll     => 1,
    -onScroll    => \&Scroll,
    -onResize    => sub {&Resize($bitmap,@_)},
    -onPaint     => sub {&Paint($memdc,@_)},
    -onMouseDown => \&MouseDown,
    -onMouseUp   => \&MouseUp,
    -onMouseMove => \&MouseMove,
    -interactive => 1,
);

#Create a memory DC compatible with the child window DC
$memdc=$ChildWin->GetDC->CreateCompatibleDC();

#show both windows and enter the Dialog phase.
$mainwin->Show();
$ChildWin->Show();

################################
# my attempt at a rectangle        
$ChildWin->SelectObject($dragpen);
$ChildWin->SelectObject($dragbrush);
$ChildWin->GetDC->Rectangle(10,10,50,50);
$ChildWin->GetDC->Validate();
################################

Win32::GUI::Dialog();

The window displays with no errors.  The rectangle is drawn with a
thin black border and a white background.  I was expecting a thick
green border with a blue background.  What am I doing wrong?

Thanks,
Chris

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to