Note that there are some explanatory texts on larger screens.

plurals
  1. POResizing window causes black strips
    text
    copied!<p>I have a form, which sets these styles in constructor:</p> <pre><code>this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.ResizeRedraw, true); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); </code></pre> <p>And I draw some rectangles in <code>Paint</code> event. There are no controls on the form. Hovewer, when I resize the form, there are black strips at right and bottom of the form. Is there any way to get rid of them? I've tried everything, listening for <code>WM_ERASEBKGND</code> in <code>WndProc</code>, manually drawing the form on <code>WM_PAINT</code>, implementing custom double buffer, etc. Is there anything else I could try?</p> <p>I've found this: <a href="https://connect.microsoft.com/VisualStudio/feedback/details/522441/custom-resizing-of-system-windows-window-flickers" rel="nofollow noreferrer">https://connect.microsoft.com/VisualStudio/feedback/details/522441/custom-resizing-of-system-windows-window-flickers</a> and it looks like it is a bug in DWM, but I just hope I can do some workaround.</p> <p>Please note that I must use double buffering, since I want to draw pretty intense graphic presentation in the <code>Paint</code> event. I develop in C# .NET 2.0, Win7.</p> <h2>Status Update 1</h2> <p>I've managed to get rid of most of the black stripes by implementing the resize functionality by myself. Hovewer there are still some minor glitches. Is there any way to do <code>resize</code> and <code>paint</code> operation at once? Here is a <strong>pseudo-code</strong> of what I need to do:</p> <pre><code>IntPtr hDC; var size = new Size(250, 200); IntPtr handle = API.PaintAndResizeBegin(this.Handle /* Form.Handle */, size.Width, size.Height, out hDC); using (var g = Graphics.FromHdc(hDC)) { this.backBuffer.Render(g, size); } API.PaintAndResizeCommit(handle); </code></pre> <p>Is there any way to implement the above code?</p> <p>The second solution could be to back-buffer whole form, including non-client area. But how to do that? I don't want to paint the non-client area by myself, as I want to keep the nice aero effect on Vista/7. Any help will be deeply appreciated.</p> <h2>Status Update 2</h2> <p>It looks like this problem is unsolvable, since it is omnipresent on Windows, in every application. We can just hope that MS will take some inspiration in Mac OS X and will provide appropriate APIs in new Windows.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload