Double buffering
-
Form an article, I read that this enables double buffering on a form:
SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true);
Well I tried it, using this code on an MDI child:Graphics g = CreateGraphics(); g.FillRectangle(new SolidBrush(somecolour), 0, 0, this.Width, this.Height);
When I enable both AllPaintingInWmPaint and DoubleBuffer, parts of the form don't get painted. I'm not sure what exactly happens, but here is an image: http://www.subspacedownloads.com/db.jpg[^] On the image, I dragged the window from behind the left edge fast(If I do it slow, it gets painted almost completely. Leaves 2-5 pixels to the left). How do I fix this? -
Form an article, I read that this enables double buffering on a form:
SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true);
Well I tried it, using this code on an MDI child:Graphics g = CreateGraphics(); g.FillRectangle(new SolidBrush(somecolour), 0, 0, this.Width, this.Height);
When I enable both AllPaintingInWmPaint and DoubleBuffer, parts of the form don't get painted. I'm not sure what exactly happens, but here is an image: http://www.subspacedownloads.com/db.jpg[^] On the image, I dragged the window from behind the left edge fast(If I do it slow, it gets painted almost completely. Leaves 2-5 pixels to the left). How do I fix this?I dont think you can UserPaint with the other two. Why are you using UserPaint? You should only use that AFAIK when you want to completely render the control without any help from Windows. I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
-
I dont think you can UserPaint with the other two. Why are you using UserPaint? You should only use that AFAIK when you want to completely render the control without any help from Windows. I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
-
Form an article, I read that this enables double buffering on a form:
SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true);
Well I tried it, using this code on an MDI child:Graphics g = CreateGraphics(); g.FillRectangle(new SolidBrush(somecolour), 0, 0, this.Width, this.Height);
When I enable both AllPaintingInWmPaint and DoubleBuffer, parts of the form don't get painted. I'm not sure what exactly happens, but here is an image: http://www.subspacedownloads.com/db.jpg[^] On the image, I dragged the window from behind the left edge fast(If I do it slow, it gets painted almost completely. Leaves 2-5 pixels to the left). How do I fix this?I think that the problem is that your painting code (which I assume is in the Paint event handler) should use the Graphics object from the PaintEventArgs parameter rather than creating its own. This seems to fix the problem. Chris Jobson
-
I think that the problem is that your painting code (which I assume is in the Paint event handler) should use the Graphics object from the PaintEventArgs parameter rather than creating its own. This seems to fix the problem. Chris Jobson