472,099 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,099 software developers and data experts.

Double Buffering on forms

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
2 3351
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
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.

Similar topics

3 posts views Thread by Alex Glass | last post: by
5 posts views Thread by DraguVaso | last post: by
1 post views Thread by Kuba Florczyk | last post: by
2 posts views Thread by Millennium Falcon | last post: by
2 posts views Thread by Dan Neely | last post: by
1 post views Thread by Brian Henry | last post: by
7 posts views Thread by Rain | last post: by
3 posts views Thread by ssoffline | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.