473,511 Members | 12,087 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3447
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2952
by: Alex Glass | last post by:
I have read plenty about applying double buffering for animation and self drawn forms. Is there a way to apply it to a form with many standard controls on it (textboxes, labels etc) ?? I have...
5
2406
by: DraguVaso | last post by:
Hi, I have my custom Inherited DataGrid. I override the OnPaint-event to speed up things and avoid flikkering using Double Buffering. To draw the normal things of the DataGrid I have to call the...
1
3092
by: Kuba Florczyk | last post by:
Hi I've got some problem doing double buffer. Here is my problem: I've got custom control on which i paint some data (chat messages, lets call it ChatControl), this control is puted on a...
2
28736
by: Millennium Falcon | last post by:
Hi! In my application, I have a panel in the middle of the form, which I'll be using as a drawing panel. I would like to update the drawing panel each time when it is required, without updating...
2
5593
by: Dan Neely | last post by:
My dialog has groupboxes with slow to redraw controls, to improve the appearance I want to doublebuffer it. While I can use SetStyle() in the Dailogs constructor the setting change doesn't get...
1
3918
by: Brian Henry | last post by:
In the documentation for the listview for owner drawn it says this Note To avoid issues with graphics flickering when owner drawing, override the ListView control and set the DoubleBuffered...
0
1367
by: Brian Henry | last post by:
I am trying to do a owner drawn list view in detail mode, when i inherited the list view into a new custom control then turned on double buffering all the sudden the selection rectangle is the...
7
6498
by: Rain | last post by:
Hello Gurus! I really need this one to finish a module in my thesis. PLease please help me. I need a double buffer class so i can call it and use it anytime i want, the problem is everything ive...
3
5938
by: ssoffline | last post by:
hi i have an app in which i can drop objects onto a form and move them, it consists of graphics (lines), i am using double buffering to avoid filckering in the parent control which is a panel,but...
0
7245
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7427
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5069
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.