Hello Raphael,

I unfortunately do not have a breadth of experience with the DC object as some on this list, but having seen this I can at least offer some tid-bit of possible use. I would say that the one means I can come to think of is ignoring repaint wherein there is no cause to redraw this particular rectangle. Ok, this sounds a simple concept, but I realize this may not be as easy to complete in reality. This of course, offers no help with the issue of the bad flicker during dragging, but it offers some to the regular usage flickering.

Jason †P

On Sun, Mar 8, 2009 at 7:54 PM, Raphael Stoeckli <win32gui@rabanti.ch> wrote:
Hi @ all

I try to plot a static DC-Object (means: the graphic is calculated uniquely
at runtime, depending of several parameters, and does not change while
displaying the window) in a window.
The problem is that this object continuously needs to be redrawn, because it
vanishes during moving the window around, or if an other window is moving
over it.
I thought, a repaint-routine like that would solve the problem:
use strict;
use Win32::GUI();
our $WIN;
our %DC;


sub build_gui # Building the GUI
$WIN = new Win32::GUI::Window(
† † †-left => 200, -top => 200, -width †=> 300, -height => 300,
† † †-name † => "WIN",
† † †-text † => "Static-DC-Test",
† † †#-noflicker => 1, # Useless/worse result
† † †);
$DC{'color'}{'white'} = [255,255,255];
$DC{'color'}{'red'} = [255,0,0];
$DC{'pen'} = new Win32::GUI::Pen( -color => $DC{'color'}{'red'}, -width =>
3, );
$DC{'brush'} = new Win32::GUI::Brush( -color => $DC{'color'}{'white'},
-width => 1, );
$DC{'timer'} = $WIN ->AddTimer("timer", 100);

sub ::timer_Timer # Repaint DC with interval of 'timer'
{ &repaint; }

sub WIN_Terminate { return -1; }

sub repaint # Create/rebuild DC-Object
$DC{'dc'}{'object'} = $WIN -> GetDC;
$DC{'dc'}{'object'} -> FillRect(10, 10, 280, 260,$DC{'brush'});
$DC{'dc'}{'object'} -> SelectObject($DC{'pen'});
$DC{'dc'}{'object'} -> BeginPath();
$DC{'dc'}{'object'} -> MoveTo(10, 10);
$DC{'dc'}{'object'} -> LineTo(280, 260);
$DC{'dc'}{'object'} -> EndPath();
$DC{'dc'}{'object'} -> StrokePath();
#$DC{'dc'}{'object'} † -> Save(); # ??? Save() --> Restore() ???
But the result of the code above is a flickering, annoying graphic.
So the next thought, was to generate a bitmap from the DC. There is, if Iím
not wrong, a method with DIBitmap. But, I would like to refrain from binding
in that module, only for converting a single graphic, because itís bloating
up the program/PAR-binary.

Sadly, the DC-Documentation is frequent a sealed book for me.
Does anyone know an easy method (I also like to take a complex solution :-))
to convert a DC into a bitmap-object, without using DIBitmap? Or, even
better, a way to prevent that flickering during the repaint?

Thanks a lot.


Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
Perl-Win32-GUI-Users mailing list