By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,563 Members | 1,280 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,563 IT Pros & Developers. It's quick & easy.

Double Buffering on forms

P: n/a
I have created a 2d isometric game map using tiles and now I'm trying to
move around my map..when i go near the edge of the map I want to redraw the
map to show new parts of the map however the screen flicker a good bit while
this happens. I'm using GDI+ and it say in MSDN that double buffering will
fix this but it didnt work for me.

this.Setstyle(Controlstyles.DoubleBuffer, true );
this.Setstyle(Controlstyles.UserPaint, true );
this.Setstyle(Controlstyles.AllPaintingInWmPaint, true);
this.Updatestyles();

I set double buffering on the form, but I wonder if the problem is that I'm
using a panel control to do all my GDI + drawing in. When I set double
buffering on a form does that include all object on the form(ie my panel). I
cant set double buffer on a panel( i tired).

What else could cause this flicker? Any ideas?

Thanks
Jason
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Setting double-bufferring on the form will not affect the components hosted
by the form. Panel does not double-buffer by default so my advise would be
to derive a class from Panel and turn on double-buffering in the constructor
of that class.

If you're drawing in response to the Panel's Paint event then you can either
move you code to the derived classes OnPaint protected method or respond to
that objects Paint event.

--
Bob Powell [MVP]
Visual C#, System.Drawing

The Image Transition Library wraps up and LED style instrumentation is
available in the June of Well Formed for C# or VB programmers
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml


"Jason" <bo******@msu.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have created a 2d isometric game map using tiles and now I'm trying to
move around my map..when i go near the edge of the map I want to redraw the map to show new parts of the map however the screen flicker a good bit while this happens. I'm using GDI+ and it say in MSDN that double buffering will
fix this but it didnt work for me.

this.Setstyle(Controlstyles.DoubleBuffer, true );
this.Setstyle(Controlstyles.UserPaint, true );
this.Setstyle(Controlstyles.AllPaintingInWmPaint, true);
this.Updatestyles();

I set double buffering on the form, but I wonder if the problem is that I'm using a panel control to do all my GDI + drawing in. When I set double
buffering on a form does that include all object on the form(ie my panel). I cant set double buffer on a panel( i tired).

What else could cause this flicker? Any ideas?

Thanks
Jason

Nov 16 '05 #2

P: n/a
I created a class called ControlMap that is derived from Control?
I left my GDI+ code in the function Paint method. Double Buffering is
working fine this way.

My new question is regarding OnKeyUp and OnKeyDown and OnKeyPress events
that are registered to the main form of the app. Before I created this
ControlMap class I was able to use the arrow keys to move around my Map, but
after creating my controlMap class the OnKeyUp and OnKeyDown events never
get raised, but it seems strange to me because the OnKeyPress event still
works fine.

Any ideas? Did you intend for me to derive from Control class or a different
class.
Thanks for the help.

Jason
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Setting double-bufferring on the form will not affect the components hosted by the form. Panel does not double-buffer by default so my advise would be
to derive a class from Panel and turn on double-buffering in the constructor of that class.

If you're drawing in response to the Panel's Paint event then you can either move you code to the derived classes OnPaint protected method or respond to that objects Paint event.

--
Bob Powell [MVP]
Visual C#, System.Drawing

The Image Transition Library wraps up and LED style instrumentation is
available in the June of Well Formed for C# or VB programmers
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml


"Jason" <bo******@msu.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have created a 2d isometric game map using tiles and now I'm trying to
move around my map..when i go near the edge of the map I want to redraw the
map to show new parts of the map however the screen flicker a good bit

while
this happens. I'm using GDI+ and it say in MSDN that double buffering will fix this but it didnt work for me.

this.Setstyle(Controlstyles.DoubleBuffer, true );
this.Setstyle(Controlstyles.UserPaint, true );
this.Setstyle(Controlstyles.AllPaintingInWmPaint, true);
this.Updatestyles();

I set double buffering on the form, but I wonder if the problem is that

I'm
using a panel control to do all my GDI + drawing in. When I set double
buffering on a form does that include all object on the form(ie my

panel). I
cant set double buffer on a panel( i tired).

What else could cause this flicker? Any ideas?

Thanks
Jason


Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.