Hello,
I managed to solve my own problem with about 3 hours of tinkering and reading
MSDN. Although I still haven't figured out how exactly WM_Paint messages are
being generated. If I comment out the Update and the InvalidateRect method
calls, the graph line still gets drawn; which means calling Show on a window
fires a WM_Paint message. Additionally, the BeginPaint and EndPaint functions,
which I couldn't find in the documentation but did find in GUI.xs, don't seem
to do anything. They are required in Win32 C programming, so I (incorrectly?)
assumed they would be needed here as well. Finally, the Validate function has
no effect, which seems to indicate the Update function does not invalidate any
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! 

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.

Best Regards,
Rod

#!c:/Perl/bin/wperl.exe -w
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 {
        my $W = $graph->ScaleWidth;
        my $H = $graph->ScaleHeight;
        my $DC = $graph->GetDC;
        #$graph->BeginPaint(); useless?
        $DC->MoveTo(0,$H);
        $DC->LineTo($W,0);
        #$DC->Validate; useless?
        #$graph->EndPaint(); useless?
        return 1;
}
sub topwin_Terminate {
        return -1;
}
sub ExitButton_Click {
        return -1;
}
exit;

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


Reply via email to