I have a form that sets these styles in the constructor:
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
And I draw some rectangles in the event Paint. There are no controls in the form. Hovewer, when I resize the form, there are black bars on the right and bottom of the form. Is there any way to get rid of them? I tried everything, listening WM_ERASEBKGNDin WndProc, manually drawing the form on WM_PAINT, implementing my own double buffer, etc. Is there anything else I could try?
I found this:
https://connect.microsoft.com/VisualStudio/feedback/details/522441/custom-resizing-of-system-windows-window-flickers
and it looks like this is a bug in DWM, but I just hope that I can make some workaround.
Please note that I have to use double buffering, since I want to make a fairly intense graphical representation in the event Paint. I am developing in C # .NET 2.0, Win7.
Status Update 1
I managed to get rid of most of the black bars by implementing the resize function myself. Hover still has some minor glitches. Is there a way to do the surgery resizeand Paintimmediately? Here is the pseudo code of what I need to do:
IntPtr hDC;
var size = new Size(250, 200);
IntPtr handle = API.PaintAndResizeBegin(this.Handle ,
size.Width, size.Height, out hDC);
using (var g = Graphics.FromHdc(hDC)) {
this.backBuffer.Render(g, size);
}
API.PaintAndResizeCommit(handle);
Is there any way to implement the above code?
The second solution may be the reverse buffer form, including the non-client area. But how to do that? I do not want to draw a non-client area myself, because I want to maintain a good aero effect for Vista / 7. Any help would be greatly appreciated.
Status Update 2
, , Windows, . , MS Mac OS X API Windows.