境界線のないウィンドウがあります。私は丸みを帯びた角をネットで検索しましたが、すべて境界線があります。フォームの角を丸くするにはどうすればよい(not with borders)
ですか? それを行う方法はありますか?
私はC#の初心者なので、説明してください...
ありがとう
これを試して:
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# で境界線が丸いフォーム?
Region プロパティは単純に角を切り取ります。角を真に丸くするには、角の丸い長方形を描く必要があります。
好きな形のイメージを描いて、透明なフォームに貼り付けると簡単かもしれません。描くのは簡単ですが、サイズを変更することはできません。
こちらのAnother Oneもチェック