Hello all . I used to problems with my program shaking when i mioved it off screen. I found code thats supposed to fix it . It came from some program i was tinkering with. Its had many complex textures and all added to its form and the form didnt shake when i move it off screen. I cant seem to find any good explanations or working code for double buffering anywhere i was wondering if somone could help me with what i have found so far ont he topic.
This is the code i dont udnerstand but seems to work for a program.
protected override void OnPaint(PaintEventArgs e)
Create an offscreen graphics object for double buffering
Bitmap offScreenBmp = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);
using (System.Drawing.Graphics g = Graphics.FromImage(offScreenBmp)) {
g.SmoothingMode = SmoothingMode.HighQuality;
// Draw the control
// drawControl(g);
// Draw the image to the screen
e.Graphics.DrawImageUnscaled(offScreenBmp, 0, 0);
}
}
Its in c but my main project is cli, so ill rewrite it in a minute if need be. The function draw control draws an led light with the g->drawline and other draw functions. In my main form in the InitializeComponent() function at the end i wrote this too.
this->DoubleBuffered = true;
Now that first chunk of code is supposed to work with this->DoubleBuffered = true; it says in the code. I can understanding how to draw an offscreen shape but i dont understand how i would apply this to somthing like a panel instead of drawing that led. Would i create an offscreen image of the texture i want to use in my form then add it to the panel?
I didnt add the code correctly to this post because i cant figure that out, I wish it was like it used to be .thanks for any advice this topic is confusing and undocumented, it required another level of forms understand that i dont have yet, thanks for any tips.