在C#窗口形式圆角 [英] Rounded Corners in C# windows forms

查看:144
本文介绍了在C#窗口形式圆角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有没有国界的窗口。我搜索了净圆角,但所有的边界。我怎样才能使表单(不带边框)的圆角?有没有办法做到这一点?

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?

我是一个新手,C#,所以请解释...

I am a newbie to c#, so please explain...

感谢

推荐答案

试试这个:

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));
        }
    }
}



从这里开始:的与圆角边框形式在C#?

这篇关于在C#窗口形式圆角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆