我有一个没有边框的窗口。我搜索网的圆角,但都有边框。如何制作(not with borders)
形式的圆角?有没有办法做到这一点?
我是c#的新手,所以请解释一下......
由于
答案 0 :(得分:33)
试试这个:
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, // height of ellipse
int nHeightEllipse // width of ellipse
);
public Form1()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 20, 20));
}
}
}
答案 1 :(得分:1)
答案 2 :(得分:0)
我找到了这段代码
为了提出圆角文本框,我开始尝试使用绘制覆盖事件,但遗憾的是没有任何结果,这是由于(我假设)文本框派生自Windows的事实。因此,我尝试重写WM_PAINT API,它具有所需的结果
http://www.codeproject.com/Articles/17453/Textbox-with-rounded-corners
由于