From: Steve P. <st...@ba...> - 2003-11-23 18:32:31
|
The Graphic object has a Paint event in which all your painting should be done. If you find that the graphic is going blank on resize or something, then you should call the Paint() event there too. see http://jeb.ca/perl/win32-gui-docs/index.pl/win32-gui-graphic for a simple example. You should VALIDATE not invalidate. Steve ----- Original Message ----- From: <rk...@wi...> To: <per...@li...> Sent: Sunday, November 23, 2003 5:58 PM Subject: [perl-win32-gui-users] Help with Win32::Gui::Graphic, WM_Paint and InvalidateRect > Hi, > I am trying to draw an interactive graph in a window, and I don't want to use > GD, ImageMagick, Freeimage or any other libraries because of portability > issues. > However, I can't figure out how to correctly use Win32::GUI::Graphic, > Win32::GUI::DC, WM_Paint and InvalidateRect. I've tried reading through some of > my MSDN docs that came with my copy of VC++ 6.0, but I couldn't figure this > out. > I also looked through the samples directory in the Win32::GUI distribution, but > none of them use the Graphic object or _Paint handlers. > > Can _Paint messages be generated only for Win32::GUI::Graphic objects? > How do I tell my program to redraw a window object? > What will cause a window object to be redrawn? > Does the entire window object have to be redrawn or can an area of > specified coordinates within the window object be redrawn? > What are the options that can be set in a "new Win32::GUI::Graphic"? I > cannot find them in GUI.xs. > Can someone share a simple, working example of the usage of > Win32::GUI::Graphic, WM_Paint, and InvalidateRect so that I can get > started on experimentation? > > Thanks in advance, > Rod > > Here is my code so far: > > #!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, > -name => "graph" > ); > > $topwin->Show(); > $topwin->graph->InvalidateRect(1); > Win32::GUI::Dialog(); > > sub topwin_Terminate { > return -1; > } > sub graph_Paint { > my $W = $topwin->ScaleWidth; > my $H = $topwin->ScaleHeight; > my $DC = $topwin->graph->GetDC; > my $P = new Win32::GUI::Pen( > -color => 'BLACK', > -width => 1, > ); > $DC->SelectObject($P); > $DC->BeginPath(); > $DC->MoveTo(50,50); > $DC->LineTo(45,75); > $DC->EndPath(); > $DC->StrokePath(); > $DC->Validate; > } > exit; > > ---------------------------------------------------------------- > This message was sent using IMP, the Internet Messaging Program. > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > |