2

I have a fairly complex user drawn control that is double buffered. Works very well, except when another window is moved over it. This results in holes in the control where it has not been refreshed. It is not repainting itself correctly. I've tried all the usual fixes...

    SetStyle(ControlStyles.UserPaint, true);
    SetStyle(ControlStyles.AllPaintingInWmPaint, true);
    SetStyle(ControlStyles.DoubleBuffer, true);

Doesn't help. As a cludge I have put a Timer control in the window and set it to refresh every 10 milliseconds. This seems extremely cludgy.

If I turn off double buffering the control refreshes correctly, but is otherwise messed up due to flickering.

Edit: there are no child windows in the user control. The entire surface of the user control is drawn in the paint event using graphics methods. Using WS_EX_COMPOSITED has fixed the drag over problem but there is a remaining problem with tooptips leaving a void area when they close. So far the only fix is the refresh timer and I am hoping someone knows more windows magic.

P a u l
  • 7,805
  • 15
  • 59
  • 92

1 Answers1

2

It sounds like you're approaching the limits of drawing in Winforms :) Have a look at the top answer to this question posted here: How to fix the flickering in User controls

Community
  • 1
  • 1
John Cornell
  • 1,087
  • 8
  • 22
  • WS_EX_COMPOSITED seems to fix the repaint with overlying windows. There is still a problem with tooltips causing a painting void area. But I am very happy to fix anything at this point. – P a u l Feb 18 '12 at 00:29