473,799 Members | 2,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(C ontrolStyles.Al lPaintingInWmPa int, true);
this.SetStyle(C ontrolStyles.Do ubleBuffer, true);
this.SetStyle(C ontrolStyles.Us erPaint, true);
this.SetStyle(C ontrolStyles.Re sizeRedraw, 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.Cli entRectangle.Wi tdh,
this.ClientRect angle.Height);
Graphics g = Graphics.FromIm age(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 3106
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.on et.pl> wrote in message
news:%2******** ********@TK2MSF TNGP12.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(C ontrolStyles.Al lPaintingInWmPa int, true);
this.SetStyle(C ontrolStyles.Do ubleBuffer, true);
this.SetStyle(C ontrolStyles.Us erPaint, true);
this.SetStyle(C ontrolStyles.Re sizeRedraw, 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.Cli entRectangle.Wi tdh,
this.ClientRect angle.Height);
Graphics g = Graphics.FromIm age(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
4458
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 menu to switch an image (actually to add rectangels offscreen and bring it to the front). The following codes runs properly. You just need to create a file images.properties and put some images in a folder called images. By the way this is...
17
12866
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. To get around this limitation on double, I'd like to keep the bits of the double the *same* but change its interpretation to long. I can use "&" on longs. I tried to use reinterpret_cast for this purpose, but it returned zero every time. double...
12
3217
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 to stdout/stderr, I'd like it to write to stdout, to a file, and/or call a logging function. So my output function might look something like this: OutputFacility& OutputFacility::put(const std::string& s) { cout << s; // print to stdout
2
15946
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 handle all the asnychronous inputs. Someone mentioned Herb Shutters book as frame of reference, nonetheless, could someone provide sample code or - in effect an outline of double buffering? I've perused the web but most references are to...
1
3391
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 example I also have a MakeCurrent() method. Inside of the overriden method for CreateParams() I also set the CS_OWNDC bit so that my control has a private DC. During instantiation of my control I make a call to User32.dll to GetDC(IntPtr...
2
3201
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 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/creatingcustomcolumns.asp The problem I am having is that the data in the custom datagridcolumn is not saved to viewstate and after postback, the column does not contain data.
5
3474
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 compilier warnings and then doesn't work correctly. I don't understand the warnings, sizeof(double) = 8. An integer has size 4 and it works fine. // THIS Works!!! unsigned int x_int = buffer<<24 | buffer<<16 | buffer<<8 | buffer; // This Does...
4
1542
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 don't want to make my object to inherit from basestring (nor I know how to do it...). Then I was left with 'buffer'. I tried to make my
21
7525
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. sprintf (and its brothers) 3. any nonstandard C/C++ functions
0
9543
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,...
1
10237
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
10029
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
9077
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
7567
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
5467
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...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.