control painting problem

  • Thread starter Thread starter mahesh.gopalan
  • Start date Start date
M

mahesh.gopalan

I created a self painted control deriving from Panel, setting the ControlStyle flags. Now once this control comes up in a form and I bring some other window (which is smaller than the control) over the control and close the other window. A black rectangular region remains where the other window was present, on the control. How do I invalidate the control to paint itself in such cases. Overriding LostFocus and GetFocus methods are not working.

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
You have to make sure you have the right flags set in ControlStyles. You can
try these settings. Should work nice:

SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
 
Yes, I am doing all that. The problem is that when some other window is placed over the control and the same window gets closed, its leaves a rectangle where the window was over the control. The control is not getting invalidated in such cases to repaint.
This is the constructor where I set the styles

public LayoutPanel()
{
SetStyle(ControlStyles.AllPaintingInWmPaint|ControlStyles.ResizeRedraw
|ControlStyles.Opaque|ControlStyles.UserPaint|ControlStyles.DoubleBuffer|ControlStyles.Selectable, true);
}

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
Hi Mahesh,

The problem probably is in the double buffering style. What happens, I
believe, is that the control has painted its face after the showing the
small control. In this case the area occupied by the control is clipped off.
When then the control is removed the double buffering kicks off and the
screen is repainted from the double buffered image (that's the prupose of
the doublebuffering, isn't it), which hasn't been painted.

If you want to invlidate the form look at Refresh, Invliadate, and Update
methods.
 
Back
Top