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

RE: DrawBorder3D query by v-jetan

v-jetan
Wed Oct 19 04:26:12 CDT 2005

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.


Re: DrawBorder3D query by Atul

Atul
Wed Oct 19 05:38:56 CDT 2005

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



"Matt" <matt12345@newsgroup.nospam> wrote in message
news:eQjw8PI1FHA.1132@TK2MSFTNGP10.phx.gbl...
> 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
>
>



Re: DrawBorder3D query by Herfried

Herfried
Wed Oct 19 07:15:49 CDT 2005

"Matt" <matt12345@newsgroup.nospam> schrieb:
> 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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Re: DrawBorder3D query by RichS

RichS
Thu Oct 20 03:32:20 CDT 2005

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





Herfried K. Wagner [MVP] wrote:
> "Matt" <matt12345@newsgroup.nospam> schrieb:
> > 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.
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://classicvb.org/petition/>


Re: DrawBorder3D query by Matt

Matt
Thu Oct 20 03:51:45 CDT 2005

Jeff,
Thanks a lot. I used your second solution. It works perfectly.

Matt

""Jeffrey Tan[MSFT]"" <v-jetan@online.microsoft.com> wrote in message
news:BZxUjUT1FHA.1468@TK2MSFTNGXA01.phx.gbl...
> Hi Matt,
>
> Thanks for your feedback.
>
> Yes, with your sample project I can reproduce out your problem. This
> behavior is by design, because we did not apply ResizeRedraw control style
> to the panel control, so then the panel's size is changed it does not
> refresh its client correctly.
>
> For this issue, I can think of 2 solutions:
> 1. Override Panel class and apply ResizeRedraw control style to it, like
> this:
> public class MyPanel : System.Windows.Forms.Panel
> {
> public MyPanel()
> {
> this.SetStyle(ControlStyles.ResizeRedraw, true);
> }
> }
>
> 2. Do not need ResizeRedraw style, but we can hook Panel.Resize event and
> explicitly doing the refresh ourselves.
> private void panelLeft_Resize(object sender, System.EventArgs e)
> {
> this.Refresh();
> }
>
> I have added these 2 solutions in your modified sample project in this
> reply. Hope it helps
>
> 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.



Re: DrawBorder3D query by v-jetan

v-jetan
Thu Oct 20 04:25:50 CDT 2005

You are welcome

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.


Re: DrawBorder3D query by Herfried

Herfried
Thu Oct 20 08:58:40 CDT 2005

"RichS" <richard.somerfield@surfcontrol.com> schrieb:
> 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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>