Hi Jeremy Thanks much for the hint. The sample-program is now 100%-non-flickering. The style => 0, made it. So the DC-issue is fully solved. Is there also such a simple trick to prevent the flickering of the other window-elements, while resizing? Near some Buttons and lables, I have two richedit-fields and two bitmaps into my window. These elements flashes still while resizing. And the noflicker-option breaks my (modified) richedit-flieds (they looks like disabled, text is disappearing etc). It's a little bit annoying, because the RE's are pretty big.
Thanks a lot. Greetings, Raphael ________________________________________ Von: Jeremy White [mailto:jez_wh...@....com] Gesendet: Freitag, 13. März 2009 20:08 An: win32...@rabanti.ch; perl-win32-gui-users@lists.sourceforge.net Betreff: RE: [perl-win32-gui-users] WG: flickering static-DC Hi, It's not a Win32-GUI problem either - it's a windows thing. When a window is resized windows clears the area *before* the paint event is fired, resulting in that flash/flicker. You can work around this by associating a class to the window (which, I think, from memory stops the event that clears the window): my $WC = new Win32::GUI::Class( -name => "test", -style => 0, ); then: $WIN = new Win32::GUI::Window( -left => 200, -top => 200, -width => 300, -height => 300, -name => "WIN", -text => "Static-DC-Test v3", -class => $WC, #-noflicker => 1, # Will not work with the Paint-event ); and that should stop the flicker. I didn't test the above, but it should work:) Cheers, Jeremy. > From: win32...@rabanti.ch > To: perl-win32-gui-users@lists.sourceforge.net > Date: Fri, 13 Mar 2009 13:33:05 +0100 > Subject: [perl-win32-gui-users] WG: flickering static-DC > > Hi @ all > > Here is a sample-programm for displaying a static DC over a memory-DC. > The sample is adapted from 'Region.pl'. > Flickering while moving the window, or moving an other window over the DC is > gone. Only while resizing the window, flickering appears. I think that is > not a DC-problem, but a win32-gui-problem > > ----------------- > # proper displaying and refreshing of a static DC > # Please see the demo 'Region.pl' for further explanations > use strict; > use Win32::GUI(); > our $WIN; > our %DC; > our @DATA; # Sample Data for the graph > > $DATA[0] = {'x' => 10, 'y' => 100}; > $DATA[1] = {'x' => 50, 'y' => 30}; > $DATA[2] = {'x' => 90, 'y' => 200}; > $DATA[3] = {'x' => 130, 'y' => 180}; > $DATA[4] = {'x' => 170, 'y' => 210}; > $DATA[5] = {'x' => 210, 'y' => 150}; > > &build_gui; # Inizialize program > Win32::GUI::Dialog(); > > 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 v3", > #-noflicker => 1, # Will not work with the Paint-event > ); > $WIN->Show(); > # Defining the DC-styles > $DC{'color'}{'white'} = [255,255,255]; > $DC{'color'}{'red'} = [255,0,0]; > $DC{'color'}{'grey'} = [100,100,100]; > $DC{'pen'} = new Win32::GUI::Pen( -color => $DC{'color'}{'red'}, -width => > 3, ); > $DC{'grid'} = new Win32::GUI::Pen( -color => $DC{'color'}{'grey'}, -width => > 1, ); > $DC{'brush'} = new Win32::GUI::Brush( -color => $DC{'color'}{'white'}, > -width => 1, ); > &repaint; # Generate the DC (first time) > } > > sub WIN_Terminate { return -1; } > > sub WIN_Paint # re-/paint-event of the window > { &repaint; } > > sub repaint # Create/rebuild DC-Object > { > # preparing the DC (memory-DC) > $DC{'dc'}{'object'} = $WIN -> GetDC; # Creating DC > $DC{'dc'}{'mem_object'} = $DC{'dc'}{'object'} -> CreateCompatibleDC(); # > Creating compatible DC > $DC{'dc'}{'bitmap'} = $DC{'dc'}{'object'} -> > CreateCompatibleBitmap(250,250); # Creating compatible Bitmap > $DC{'dc'}{'old_bitmap'} = $DC{'dc'}{'mem_object'} -> > SelectObject($DC{'dc'}{'bitmap'}); # Selecting the bitmap into the new DC > > # Drawing into the memory-DC > $DC{'dc'}{'mem_object'} -> FillRect(10, 10, 260, 260,$DC{'brush'}); > $DC{'dc'}{'mem_object'} -> SelectObject($DC{'grid'}); > for (my $i = 10;$i < 270; $i+=24) # Create y-grid > {$DC{'dc'}{'mem_object'} -> Line(10,$i,250,$i);} > for (my $i = 10;$i < 280; $i+=24) # Create x-grid > {$DC{'dc'}{'mem_object'} -> Line($i,10,$i,260);} > > $DC{'dc'}{'mem_object'} -> SelectObject($DC{'pen'}); > $DC{'dc'}{'mem_object'} -> BeginPath(); > $DC{'dc'}{'mem_object'} -> MoveTo($DATA[0]{'x'}, $DATA[0]{'y'}); # Create > graph (first point) > for (my $i = 1;$i < scalar @DATA;$i++) > { $DC{'dc'}{'mem_object'} -> LineTo($DATA[$i]{'x'}, $DATA[$i]{'y'}); } # > Steps > $DC{'dc'}{'mem_object'} -> EndPath(); > $DC{'dc'}{'mem_object'} -> StrokePath(); > > $DC{'dc'}{'object'} -> BitBlt(10, 10, 250,250,$DC{'dc'}{'mem_object'}, 10, > 10); # Updating the screen > $DC{'dc'}{'mem_object'} -> SelectObject($DC{'dc'}{'old_bitmap'}); # > Restoring original bitmap > $DC{'dc'}{'mem_object'} -> DeleteDC(); # Removing the memory-DC > } > ----------------- > Hope, the mail-linebreaks don't messing up the code > > Greetings, > Raphael > > -----Ursprüngliche Nachricht----- > Von: Raphael Stoeckli [mailto:win32...@....ch] > Gesendet: Mittwoch, 11. März 2009 00:53 > An: 'zak3' > Cc: perl-win32-gui-users@lists.sourceforge.net > Betreff: Re: [perl-win32-gui-users] flickering static-DC > > Hi Zak > > I run probably an old version of ASPerl (5.8.6.811). There is an error, when > I try to run test8.pl or test13.pl. Hook Perl_newXS_flags was not found in > perl58.dll. I think, I remained on 5.8.6.811, because of some > PAR-compatibility-issues (most likely obsolote now). I will try it on an > other machine with 5.8.8 or 5.10 the next days. > My program works now pretty good, without much flickering, only with > win32-GUI-corefunctions. I will also try to move my window-DC into a > memory-DC the next days, as I said in my last post. I will post some > sample-code when I finished that. > To tell the truth, DIBitmap and GD frighten me a little bit. Is not that I > don't understand it already worked with DIBitmap intensively. But my > program will be a standalone-binary for PCs without Perl. Even though > 1TB-HDDs are on the advance, I am still skeptic if I have a binary of more > than 3 or 4 MB in front of me, to run a really simple program. Maybe I am > too conservative :-) > > Anyhow, much thanks for your hint. I will also study the two posts from > mail-archive.com. > > Greetings, > Raphael > > -----Ursprüngliche Nachricht----- > Von: zak3 [mailto:zak31...@.....com] > Gesendet: Montag, 9. März 2009 12:57 > An: perl-win32-gui-users@lists.sourceforge.net > Betreff: Re: [perl-win32-gui-users] flickering static-DC > > > Hi > also look to this link about drawing and refreshing: > http://www.nabble.com/Draw-on-click-and-refresh-the-window---resolved-td1809 > 3899.html > and the two tutorials by rob may about drawing and refreshing: > http://www.mail-archive.com/perl-win32-gui-users@lists.sourceforge.net/msg05 > 194.html > http://www.mail-archive.com/perl-win32-gui-users@lists.sourceforge.net/msg05 > 195.html > > also before three days i have found an example in the win32gui demos : > demos\DIBitmap\ the first is test8.pl and test13.pl they draw a circle > without any flickering, they use GD graphics with DIBitmap, first install GD > Graphics from this site:http://www.bribes.org/perl/ppmdir.html > using the command: > ppm install http://www.bribes.org/perl/ppm/GD.ppd > and try the test8.pl and test13.pl, the GD graphics have many plotting > statements for drawing lines, polygons, points, etc > > > Raphael Stoeckli 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; > > > > &build_gui; > > Win32::GUI::Dialog(); > > > > 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 > > ); > > $WIN->Show(); > > $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, ); > > &repaint; > > $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 > > Im > > not wrong, a method with DIBitmap. But, I would like to refrain from > > binding > > in that module, only for converting a single graphic, because its > > 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. > > > > Regards, > > Raphael > > > > > > > ---------------------------------------------------------------------------- > -- > > 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 > > http://p.sf.net/sfu/XcvMzF8H > > _______________________________________________ > > Perl-Win32-GUI-Users mailing list > > Perl-Win32-GUI-Users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > > http://perl-win32-gui.sourceforge.net/ > > > > > > -- > View this message in context: > http://www.nabble.com/flickering-static-DC-tp22404906p22411762.html > Sent from the perl-win32-gui-users mailing list archive at Nabble.com. > > > ---------------------------------------------------------------------------- > -- > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Perl-Win32-GUI-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > > > ---------------------------------------------------------------------------- > -- > Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are > powering Web 2.0 with engaging, cross-platform capabilities. Quickly and > easily build your RIAs with Flex Builder, the Eclipse(TM)based development > software that enables intelligent coding and step-through debugging. > Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Perl-Win32-GUI-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > > > ---------------------------------------------------------------------------- -- > Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are > powering Web 2.0 with engaging, cross-platform capabilities. Quickly and > easily build your RIAs with Flex Builder, the Eclipse(TM)based development > software that enables intelligent coding and step-through debugging. > Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Perl-Win32-GUI-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ ________________________________________ Windows Live just got better. Find out more! ------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ Perl-Win32-GUI-Users mailing list Perl-Win32-GUI-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users http://perl-win32-gui.sourceforge.net/