473,395 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Custom double buffer

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);
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);

Everything is ok,but i've got some performance problems. Chat messages
arrived in every 5 seconds, and i call on ChatControl Refresh(), so my
OnPaint method is called - and thats ok. But control is repainted more times
than on in every 5 second refresh: user used scroll, or something like that.

And now i want to made some additional double buffer, because i want to draw
remembered graphic (thru bitmap), than draw it again - because its neccesery
when i only refresh control. I know i should do something like this:

Bitmap bmp = new Bitmap(this.ClientRectangle.Witdh,
this.ClientRectangle.Height);
Graphics g = Graphics.FromImage(bmp);

and than i should draw on g

but there is a "small" problem - beacuse i know control size after i draw
something (thats depends at chat messages count)! so how i can get a bitmap
from my base graphics or how to create bitmap that will resize automaticly
to my graphic size ? Or .... maybe somebody got any idea?

regards
kuba florczyk
Nov 16 '05 #1
1 3080
You should possibly consider manual double buffering. What you're doing is
essentially double buffering and then writing that the the systems
back-buffer so you might as well do it yourself.

Windows Forms Tips and Tricks has an article on double buffering and shows
you how to manage a back-buffer that changes size in response to the
OnSizeChanged method calls.

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

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

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

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Kuba Florczyk" <cz**@poczta.onet.pl> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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);
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);

Everything is ok,but i've got some performance problems. Chat messages
arrived in every 5 seconds, and i call on ChatControl Refresh(), so my
OnPaint method is called - and thats ok. But control is repainted more times than on in every 5 second refresh: user used scroll, or something like that.
And now i want to made some additional double buffer, because i want to draw remembered graphic (thru bitmap), than draw it again - because its neccesery when i only refresh control. I know i should do something like this:

Bitmap bmp = new Bitmap(this.ClientRectangle.Witdh,
this.ClientRectangle.Height);
Graphics g = Graphics.FromImage(bmp);

and than i should draw on g

but there is a "small" problem - beacuse i know control size after i draw
something (thats depends at chat messages count)! so how i can get a bitmap from my base graphics or how to create bitmap that will resize automaticly
to my graphic size ? Or .... maybe somebody got any idea?

regards
kuba florczyk

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: David | last post by:
Hello I'm writting an apllication and i like to display and offscreen image. However my code doesn't seem to work. It compiles and runs properly but What i want is to associate the button of the...
17
by: Suzanne Vogel | last post by:
I'd like to convert a double to a binary representation. I can use the "&" bit operation with a bit mask to convert *non* float types to binary representations, but I can't use "&" on doubles. ...
12
by: Matt Garman | last post by:
I'd like to create a "custom output facility". In other words, I want an object whose use is similar to std::cout/std::cerr, but offers more flexibility. Instead of simply writing the parameter...
2
by: MPowell | last post by:
Gents/Ladies, I'm doing (at least plan on ) lots of Reads and Writes across a communication channel. I'm told that for the 'receive side' it'd be prudent to implement a double buffering scheme to...
1
by: Dennis | last post by:
I'm using VS 2003 my project uses COM interop and the Tao Framework. I have a custom control derived from UserControl. It implements many functions similar to the Tao's SimpleOpenGLControl, for...
2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
5
by: DBuss | last post by:
I'm trying to convert a binary data feed into something more friendly. Some of the data is Int (and extracts successfully), but some is Double and doesn't. The below line of code gives harsh...
4
by: brunovianarezende | last post by:
Hi, sorry if this is a faq. I've searched and got no result. I'm willing to pass a custom object to re.search method, but I'm getting the error: TypeError: expected string or buffer I...
21
by: Aman JIANG | last post by:
hi I need to do this (convert double to string) fast, safe and portable. Is there any way to do this ? Except the ways following: 1. C++ I/O stream, stringstream (and boost::lexical_cast) 2....
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.