110,545
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace WindowsApplication282
{
public partial class Form1 : Form
{
Button B = new Button();
public Form1()
{
InitializeComponent();
B.Parent=this;
B.Size = new Size(100, 100);
GraphicsPath GP = new GraphicsPath();
GP.AddEllipse(10,10, 80, 80);
B.Region = new Region(GP);
B.Paint += new PaintEventHandler(B_Paint);
}
void B_Paint(object sender, PaintEventArgs e)
{
Pen P = new Pen(Color.Gray);
P.Width = 10;
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
e.Graphics.DrawEllipse(P, new Rectangle(10, 10, 80, 80));
if (this.ActiveControl == B && Control.MouseButtons == MouseButtons.Left)
e.Graphics.DrawEllipse(Pens.Black, new Rectangle(15, 15, 70, 70));
}
}
}