473,748 Members | 2,121 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(C ontrolstyles.Do ubleBuffer, true );
this.Setstyle(C ontrolstyles.Us erPaint, true );
this.Setstyle(C ontrolstyles.Al lPaintingInWmPa int, true);
this.Updatestyl es();

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 3461
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.e du> wrote in message
news:%2******** ********@tk2msf tngp13.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(C ontrolstyles.Do ubleBuffer, true );
this.Setstyle(C ontrolstyles.Us erPaint, true );
this.Setstyle(C ontrolstyles.Al lPaintingInWmPa int, true);
this.Updatestyl es();

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@_spamkille r_bobpowell.net > wrote in message
news:%2******** *******@TK2MSFT NGP09.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.e du> wrote in message
news:%2******** ********@tk2msf tngp13.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(C ontrolstyles.Do ubleBuffer, true );
this.Setstyle(C ontrolstyles.Us erPaint, true );
this.Setstyle(C ontrolstyles.Al lPaintingInWmPa int, true);
this.Updatestyl es();

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
2983
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 tried using myForm.SetStyles(ControlStyles.DoubleBuffer, True) however it has made no impact on the drawing operation. Any clarification would be greatly appreciated -Alex
5
2426
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 MyBase.OnPain(pe). But in my opinion it doesn't seem to be painted on the buffer. Everything works fine, but I think it should work better if my MyBase.OnPaint also painted in my buffer. Am I wrong? And how should I do this? I kind of need to...
1
3100
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 scrollable panel. Of course i've set right styles on a ChatControl: //styles this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
2
28780
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 the form as a whole. The following snippet makes compiler mad : this.DXPanel.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
2
5611
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 propagated to the groupbox, and since it's a protected method I can't call groupbox.SetStyle(). I've tried deriving a custom class from System.Windows.Forms.GroupBox and calling SetStyle from inside of it's constructor and from a new method. Both...
1
3933
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 property to true. Now, I am owner drawing my list view items, and yes it does flicker a lot...
0
1382
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 alpha channel transparent one that windows xp's shell uses... is there any way to just keep the standard dotted rectangle one? because performance is slow when the transparent rectangle region is enabled with double buffering... but i cant find a way...
7
6513
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 tried as a class doesnt work.. please please help. I only need the double buffering of controls, graphics... as a class. Can anyone help me with this? Thank You so so much in advacne. I would really appreciate any help.
3
5949
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 when i add controls to this panel dyanamically, the double buffering effect is not there, i move all lines connceted to a control when the control is moved , at this time flickering occurs,also when i enable double buffering for a child control...
0
8983
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8822
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9359
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9310
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9236
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8235
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6792
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4592
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2774
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.