[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

John Parrish

1/13/2005 3:00:00 PM

I?ve been doing some work with the GDI+ aspects of the .NET framework to
further my ability to write custom controls. I have noticed some things
that are frustrating to me, and I am wondering if maybe someone would be
kind enough to explain, or point me in the right direction.

First things first, my general approach to drawing in WinForms, is to
write classes/components that are passed a Graphics object on which to
draw. The parent form will override OnPaint and call the respective Draw
methods for each component that needs to render some form of output onto
the form?s graphic surface.

A simple example is a component that is responsible for allowing a user
to drag with their mouse a line. I have this working reasonably well by
wiring the MouseDown, MouseUp, and MouseMove events of the form to
handlers that I have written in the LineDrawing component.

The LineDraw component also has an event called DrawParametersChanged
which the form subscribes to so that if the user has clicked and dragged
a new end-point, the form invalidates causing the LineDraw component to
draw the new line with the new end point.

Problem 1: When I enable double buffering, I end up seeing more
flickering with this scenario than when double buffering is not enabled
at all.

Problem 2: If I have another component, that wants to render a
rectangle, or even worse a Bitmap, the calls to Invalidate to update my
Line, cause horrible flickering that I have not been able to correct in
either situation of double buffering being on or off.

Maybe I need to buy a book on GDI+ with .NET or look at some successful
implementations, it seems that what I felt is a logical way to approach
this sort of development is not working very well. Thanks for any input
you can provide.
2 Answers

Marius Ebel

1/15/2005 11:37:00 PM

0

A solution for the flickering would be the setStyle method. Look at the
following line code and place it in the load event of the form or the
control.

this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint,
true);

I don't know if it works with version 1.1 of the .NET-Framework, but
with 2.0 it works.

Marius Ebel





*** Sent via Developersdex http://www.develop... ***
Don't just participate in USENET...get rewarded for it!

John Parrish

1/16/2005 12:19:00 AM

0

Marius Ebel wrote:
> A solution for the flickering would be the setStyle method. Look at the
> following line code and place it in the load event of the form or the
> control.
>
> this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
> ControlStyles.AllPaintingInWmPaint,
> true);
>
> I don't know if it works with version 1.1 of the .NET-Framework, but
> with 2.0 it works.

Thanks

1.1 doesn't contain a ControlStyle member of "OptimizedDoubleBuffer".