DrawBorder3D query

M

Matt

Hi

In my Explorer look application, i want the panels to have a 3D look, so i
used the following.
private void panel_Paint(object sender, System.Windows.Forms.PaintEventArgs
e)
{
base.OnPaint (e);
Rectangle borderRectangle = this.ClientRectangle;
ControlPaint.DrawBorder3D(e.Graphics, borderRectangle,
Border3DStyle.Etched);
}

This is working but problem is, when the spliter window is resized the
rectangle is drawn to the new size without cleaning the old rectangle.
After resizing the panel has 2 rectangles.
How can i clear the old border before drawing the new one ?

Thanks

Matt
 
J

Jeffrey Tan[MSFT]

Hi Matt,

Thanks for your post.

Based on my knowledge, normally, this will not happen at all. Because when
the splitter control is moved to resize the window, the original part will
become invalid, and will be refreshed with the new drawing. So there should
not be this problem.

Can you provide a little sample project for us to reproduce out your
problem? Then we can understand it much better. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
A

Atul

You can first fill the entire panel with the "windows" color and then draw
the border.

----------------
-Atul, Sky Software http://www.ssware.com
Shell MegaPack For .Net & ActiveX
Windows Explorer GUI Controls
&
Quick-Launch Like Appbars, MSN/Office2003 Style Popups,
System Tray Icons and Shortcuts/Internet Shortcuts
 
H

Herfried K. Wagner [MVP]

Matt said:
private void panel_Paint(object sender,
System.Windows.Forms.PaintEventArgs
e)
{
base.OnPaint (e);
Rectangle borderRectangle = this.ClientRectangle;
ControlPaint.DrawBorder3D(e.Graphics, borderRectangle,
Border3DStyle.Etched);
}

This is working but problem is, when the spliter window is resized the
rectangle is drawn to the new size without cleaning the old rectangle.
After resizing the panel has 2 rectangles.
How can i clear the old border before dra

You can clear the control using 'e.Graphics.Clear(this.BackColor)'.
Afterwards draw the new border.
 
R

RichS

Just a thought....

Create a custom Panel class that derives from the
System.Windows.Forms.Panel

and in the constructor for your custom Panel add this line:

this.SetStyle( ControlStyles.ResizeRedraw, true );


Then make sure to update your code to use the CustomPanel rather than
the standard System.Windows.Forms.Panel.


RichS
 
H

Herfried K. Wagner [MVP]

RichS said:
Create a custom Panel class that derives from the
System.Windows.Forms.Panel

and in the constructor for your custom Panel add this line:

this.SetStyle( ControlStyles.ResizeRedraw, true );

To make sure the styles get updated I'd call 'this.UpdateStyles()' here too.
 

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