C# 带有圆圈200x200的窗口200x200不适合

C# 带有圆圈200x200的窗口200x200不适合,c#,winforms,C#,Winforms,我正在尝试做一些非常简单的事情。我正在尝试创建一个窗口,其中有一个圆,非常适合。我把窗户做成200x200,圆圈做成200x200,看起来像这样 这是我写的代码: using System.Windows.Forms; using System.Drawing; class HalloForm : Form { public HalloForm() { this.Text = "Hallo"; this.BackColor = Color.Lig

我正在尝试做一些非常简单的事情。我正在尝试创建一个窗口,其中有一个圆,非常适合。我把窗户做成200x200,圆圈做成200x200,看起来像这样

这是我写的代码:

using System.Windows.Forms;
using System.Drawing;

class HalloForm : Form
{
    public HalloForm()
    {
        this.Text = "Hallo";
        this.BackColor = Color.LightGray;
        this.Size = new Size(200, 200);
        this.Paint += this.tekenScherm;
        this.AutoScaleMode = AutoScaleMode.Font;
    }

    void tekenScherm(object obj, PaintEventArgs pea)
    {

        tekenSmiley(pea, 0, 0, 200);
        /*pea.Graphics.DrawString("Hallo!"
                               , new Font("Tahoma", 30)
                               , Brushes.Blue
                               , 10, 10
                               );*/

        //pea.Graphics.DrawArc(Pens.Black, )

        //pea.Graphics.FillEllipse(Brushes.Black, new Rectangle(new Point(x + 40, y + 40), new Size(50, 50)));
        //pea.Graphics.FillEllipse(Brushes.Black, new Rectangle(new Point(x + 110, y + 40), new Size(50, 50)));
        //pea.Graphics.FillPolygon(Brushes.Black, new Point[] { new Point(x + 85, x + 120), new Point(x + 115, y + 120), new Point(x + 100, x + 90) });
    }

    private void tekenSmiley(PaintEventArgs pea, int x, int y, int grootte)
    {
        pea.Graphics.FillEllipse(Brushes.Yellow, new Rectangle(new Point(x, y), new Size(grootte, grootte)));
    }
}

class HalloWin3
{
    static void Main()
    {
        HalloForm scherm;
        scherm = new HalloForm();
        Application.Run(scherm);
    }
}

我尝试了不同的自动缩放模式,但都没有改变任何东西。你能帮我找出为什么这个圆圈不适合放在窗户里吗。我知道它可能不适合垂直方向,因为顶部栏可能包含在高度中,但它应该仍然适合水平方向。

如您所述,表单的大小包括边框、标题栏等。因此,请尝试设置定义表单客户端区域的ClientSize:

this.ClientSize = new Size(200, 200);

如前所述,表单的大小包括边框、标题栏等。因此,请尝试设置定义表单客户端区域的ClientSize:

this.ClientSize = new Size(200, 200);

您使用的是Windows10,它使用透明边框。他们仍然在那里,鼠标在他们附近盘旋,只是看不见而已。您需要设置ClientSize属性,以保证其适合。谢谢您的回答,这确实有效。您使用的是Windows10,它使用透明边框。他们仍然在那里,鼠标在他们附近盘旋,只是看不见而已。您需要设置ClientSize属性,以保证它适合。谢谢您的回答,这确实有效。