Hi,
the following code will draw a line from top left to bottom right in win32gui and TK, the condition is that i must draw it once only ie executing the plotting code once only.
win32gui :
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 a line", ##-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); } ##$DC->Validate(); $NumberOfLinesDrawn +=1; print "$NumberOfLinesDrawn\n"; }
so in win32gui how to keep the plot from been erased when covered by other windows !!. the usual plan for this is to redraw the same line code again and again if you uncomment the lines:
-onPaint => \&Draw ##and $DC->Validate();
but i think this is not the same way other modules or languages deals with updating the window ie by updating the pixels of the screen, in comparison the same TK code is concise and working well:
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 => '.'); } $mw->update; $NumberOfLinesDrawn +=1; print "$NumberOfLinesDrawn\n"; MainLoop;

In reply to updating the window in Win32 GUI by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.