From: [EMAIL PROTECTED]
windows. So the WM_Paint message is being generated for a reason other than a
window being declared invalidated. Could someone clarify any of this? I'm
finding Win32 to be very complicated!

It does seem complicated, but is straight forward once you know what is going on. The paint event is generated by windows *every time* a part of your window needs to be redrawn. For example, if another window is dragged over yours you will receive a paint event for the area that needs to be redrawn. The "lazy" approach is to just redraw the whole window, but you could just draw what is needed. Once you have redrawn your window, you *must* tell windows you have finished - and you do this by the validate method. If you do not validate, windows will just keep sending you paint events.

Anyways, since there is not alot of documentation nor example code for
Win32::GUI, I'll show my simple code just in case someone else ever
needs to learn how to do this.

The code you shown was mostly correct, but you *must* include the validate response, i.e.:

use strict;
use Win32::GUI;

my $topwin = new Win32::GUI::Window(
             -name   => 'topwin',
             -title => 'window',
             -width  => 800,
             -height => 600,
             -pos => [125,75],
              -maximizebox => "0",
              -minimizebox => "0",
              -resizable => "0"
);

my $graph = new Win32::GUI::Graphic(
        $topwin,
        -left => 0,
        -top => 0,
        -width => $topwin->ScaleWidth,#same width as parent window
        -height => $topwin->ScaleHeight,#same height as parent window
        -name => "graph",
);
$topwin->Show();
$graph->Show();
#$graph->Update(); Send WM_Paint message for the graphic control window?
#GUI::InvalidateRect($topwin,1);

Win32::GUI::Dialog();

sub graph_Paint {
       print 'in paint';
        my $W = $graph->ScaleWidth;
        my $H = $graph->ScaleHeight;
        my $DC = $graph->GetDC;
       $DC->MoveTo(0,$H);
       $DC->LineTo($W,0);
       $DC->Validate; #<------ MUST HAVE
       return 1;
}
sub topwin_Terminate {
       return -1;
}
sub ExitButton_Click {
        return -1;
}
exit;

_________________________________________________________________
Hotmail messages direct to your mobile phone http://www.msn.co.uk/msnmobile


Reply via email to