Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / April 2006

Tip: Looking for answers? Try searching our database.

How does one create a rounded window?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
zorro - 25 Apr 2006 18:20 GMT
Hello,
I want to have a window skin with rounded corners and where the
system's usual window frame is hidden, like in Windows Media Player.
Can I do this with Windows.Forms? Is it just a matter of setting some
property, like "myframe.visibility=false"?

nu-b
Stoitcho Goutsev (100) - 25 Apr 2006 19:29 GMT
zorro,
you can use Control.Region property to crop the control in any shape you
want.

Signature

HTH
Stoitcho Goutsev (100)

> Hello,
> I want to have a window skin with rounded corners and where the
[quoted text clipped - 3 lines]
>
> nu-b
Michael Powell - 26 Apr 2006 09:12 GMT
Hi,
Changing the region works, the only problem with this is that if you are
using any SmoothingMode to make the edges of the window took nice, you need
to clip the region to a few pixels bigger than your actual window.  If you
do not do this you will end up with a very ugly pixelized edge.

Signature

Mike Powell
Ramuseco Limited
www.ramuseco.com

> zorro,
> you can use Control.Region property to crop the control in any shape you
[quoted text clipped - 7 lines]
>>
>> nu-b
Chris Dunaway - 26 Apr 2006 17:01 GMT
Do you have any code samples that demonstrate this?  I created a
rounded button, but like you said, the edges are pixellated.  Is it
just a matter of growing the region by one pixel?

I would like to get a nicely antialiased edge based on the background
color of the control where the button is placed.

For reference what I do with my button is create a GraphicsPath object
in the shape I want (in this case it is just rounded edges) and create
a region based on that GraphicsPath.  I then use various drawing
commands to fill the interior of the button, typically with a gradient
fill.  I would like to be able to anti-alias the edge of the button
against the background of the controll on which it is placed.  

Thanks
Michael Powell - 29 Apr 2006 13:39 GMT
Here is a quick control i created which illustrates how this works, you'll
notice that the control is 1 pixel smaller than the region, this allows the
small margin required by the SmoothingMode.AntiAlias, the edges are smooth
and it works for every shape that i've used it for (circles, ellipses,
rounded rectangles...)
using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Drawing;

using System.Drawing.Drawing2D;

using System.Data;

using System.Text;

using System.Windows.Forms;

namespace RoundRegionSmoothEdges

{

public partial class UserControl1 : UserControl

{

public UserControl1()

{

this.SetStyle(ControlStyles.SupportsTransparentBackColor |
ControlStyles.OptimizedDoubleBuffer , true);

this.BackColor = Color.Transparent;

InitializeComponent();

}

protected override void OnPaint(PaintEventArgs e)

{

e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

GraphicsPath backPath = new GraphicsPath();

GraphicsPath forePath = new GraphicsPath();

backPath.AddEllipse(this.ClientRectangle);

forePath.AddEllipse(new Rectangle(1, 1, this.ClientRectangle.Width - 2,
this.ClientRectangle.Height - 2));

this.Region = new Region(backPath);

e.Graphics.FillPath(Brushes.Blue, forePath);

base.OnPaint(e);

}

}

}

Signature

Mike Powell
Ramuseco Limited
www.ramuseco.com

> Do you have any code samples that demonstrate this?  I created a
> rounded button, but like you said, the edges are pixellated.  Is it
[quoted text clipped - 11 lines]
>
> Thanks

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.