好的,我已经用这个代码做了一个表单:this.FormBorderStyle = FormBorderStyle.None;好的,我还用这个代码添加了一个边界半径:
[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 Form4()
{
InitializeComponent();
Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 20, 20));
}所以,我需要的是在窗体周围添加一个小的黑色边框,该边框与边界半径成曲线。我该怎么做?
好的,我添加了这个,它起作用了,但它不与边界一起工作,它只是变得简单:e.Graphics.DrawRectangle(Pens.Black, new Rectangle(0, 0, Width - 1, Height - 1));和这个:
ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, Color.Black, ButtonBorderStyle.Solid);发布于 2012-05-20 22:57:58
覆盖表单的OnPaintBackground()方法,并使用传递的e.Graphics对象,使用Graphics方法简单地绘制边框。
请注意,在使用区域(GraphicsPath)构造函数时,不必使用pinvoke。同样的GraphicsPath也可以方便地绘制边框。
https://stackoverflow.com/questions/10674383
复制相似问题