0

わかりました、私はこのコードでフォームを作成しました: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);
4

1 に答える 1

1

フォームの OnPaintBackground() メソッドをオーバーライドし、渡された e.Graphics オブジェクトを使用して Graphics メソッドで単純に境界線を描画します。

Region(GraphicsPath) コンストラクターを使用する場合は、ピンボークする必要がないことに注意してください。同じ GraphicsPath は、境界線を描画するのにも便利です。

于 2012-05-20T14:57:57.810 に答える