I have a window without borders. I searched net for rounded corners but all with borders. How can i make rounded corners of the form(not with borders)
? Is there a way to do that?
I am a newbie to c#, so please explain...
Thanks
尝试这个:
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
[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, // width of ellipse
int nHeightEllipse // height of ellipse
);
public Form1()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 20, 20));
}
}
}
从这里开始:C# 中带有圆角边框的表单?
我找到了这段代码
为了提出圆角文本框,我开始尝试使用绘制覆盖事件,但不幸的是没有任何结果,这是由于(我假设)文本框是从 Windows 派生的事实。因此,我尝试改写 WM_PAINT API,得到了预期的结果
http://www.codeproject.com/Articles/17453/Textbox-with-rounded-corners
谢谢