473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How do I create windows forms with rounded corners?

"David" <da*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
so, the questuion,
How can I create windows (forms) with rounded corners?

David.

Nov 16 '05 #1
3 41774
hi David
what you can do is to use the classes of Graphics to override the Onpaint
method of the form ( where the form is printed ) you may need to read about
using GDI classes.
check these articles

http://www.devhood.com/tutorials/tut...tutorial_id=24
http://www.dotnet247.com/247reference/msgs/2/11921.aspx
http://www.c-sharpcorner.com/2/gdi_plus.asp

Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #2
There's a much easier way to round the edges of a windows control. Use the
Windows API function CreateRoundRectRgn(). The abbreviated example below
shows how to do it to a form.

yourform.cs
....
using System.Runtime.InteropServices;
....
[DllImport("Gdi32.dll", EntryPoint="CreateRoundRectRgn")]
private static extern IntPtr CreateRoundRectRgn
(
int nLeftRect, // x-coordinate of upper-left corner
int nTopRect, // y-coordinate of upper-left corner
int nRightRect, // x-coordinate of lower-right corner
int nBottomRect, // y-coordinate of lower-right corner
int nWidthEllipse, // height of ellipse
int nHeightEllipse // width of ellipse
);

public Form1() // Your form's or other control's constructor
{
InitializeComponent();
Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn( 0, 0,
Width-10, Height-10, 20, 20)); // adjust these parameters to get the look
you want.
}
....

ShaneB

"Mohamoss" <mo************@egdsc.microsoft.com> wrote in message
news:H%****************@cpmsftngxa10.phx.gbl...
hi David
what you can do is to use the classes of Graphics to override the Onpaint
method of the form ( where the form is printed ) you may need to read
about
using GDI classes.
check these articles

http://www.devhood.com/tutorials/tut...tutorial_id=24
http://www.dotnet247.com/247reference/msgs/2/11921.aspx
http://www.c-sharpcorner.com/2/gdi_plus.asp

Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #3
ShaneB,

Thanks for helping David.
I came in between because he wasn't asking his question in a way that would
get him an answer.
He has the answer now. Thanks again.
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Konrad | last post by:
Hi This is maybe simple question but how to render DataGrid and Tables with rounded corners? Thanks Konrad
3
by: Rod Gill | last post by:
Hi, VB.Net, Visual Studio 2003, Windows Application I want to avoid the old Windows rectangle shape, but I don't need or want complex bitmaps. What's the easiest way to create a form with...
2
by: Dino Buljubasic | last post by:
Hi, I have several panels that holds bunch of controls with information on my forms. My form has background image property set to an image that has borders defining where my panel comes and...
8
by: TheCornjerker | last post by:
I've been looking into what method I should use to show rounded corners (and I've found a lot). My question is why does Google seems to mostly use the table method with an image in each corner. ...
6
by: Schraalhans Keukenmeester | last post by:
I want to achieve the following: A small image in each of the corners of a box, like below: +-------------------------------+ | + | + | + | + | + | +
1
by: kidelectric | last post by:
The issue I am having is that I would like to be able to drag-and-drop div elements that have rounded corners.* Since these elements will be dynamically created (including background color), I could...
4
by: PWS | last post by:
I am despertely trying get a DIV to look like a box with rounded corners. I can find load of examples this where the first line of text has the top graphic and the last line of text has the...
2
by: Terry | last post by:
Hi folks. I was wondering what people here think is the best way to create rounded corners on divs. I am hoping that the implementation is pure css and does not involve the addition of extra...
6
by: moondaddy | last post by:
I need to be able to make polygons with rounded corners. This will be to draw group outlines around shapes in a diagramming tool in wpf. all angles in the polygon will be 90 degrees, but somehow...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.