From: merryxmas <mer...@ya...> - 2010-01-07 08:13:13
|
Hi, the following code will draw a line advancing slowly from top left to bottom right, the condition is that i must draw it once only. so how i keep the plot from been erased when covered by other windows !!. i have tried many plans but failed. there is Update, and restore functions but it seems it is not working. after the wingui code i present a TK code to the same problem and it is working well. i wish you all a happy new year 2010 use strict; use warnings; use Win32::GUI(); our $NumberOfLinesDrawn = 0; my $Win = new Win32::GUI::Window( -left => 0, -top => 0, -width => 500, -height => 400, -name => "Window", -text => "drawing line with animation", #-onPaint => \&Draw, ); $Win->Show(); Draw(); Win32::GUI::Dialog(); sub Window_Terminate { return -1; } sub Draw { my $DC = $Win->GetDC; my $x = 0; my $y = 0; for(1..300) {$y +=1; $x +=1; $DC->SetPixel($x,$y); #slowing the plot process: my $counter = 0; while($counter<100000){$counter+=1;} Win32::GUI::DoEvents; } #$DC->Validate(); $NumberOfLinesDrawn +=1; print "$NumberOfLinesDrawn\n"; } the TK code: use warnings; use strict; use Tk; my $mw = MainWindow->new; my $x = 0; my $y = 0; my $counter=0; our $NumberOfLinesDrawn = 0; my $c = $mw->Canvas(-width => 500, -height => 500); $c ->pack; for(1..300) {$y +=1; $x +=1; $c -> createText( $x, $y, -fill => 'red', -text => '.'); $counter=0; # delay loop while ($counter <= 100000) { $counter++; } $mw->update; } $NumberOfLinesDrawn +=1; print "$NumberOfLinesDrawn\n"; MainLoop; -- View this message in context: http://old.nabble.com/updating-the-window-screen-tp27056406p27056406.html Sent from the perl-win32-gui-users mailing list archive at Nabble.com. |