control painting problem

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...
 
G

Guest

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);
 
M

mahesh.gopalan

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...
 
S

Stoitcho Goutsev \(100\) [C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top