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