步骤如下:
1.新建窗体,并隐藏标题栏。
2.导入图片为窗体BackgroundImage。适当将BackgroundImageLayout属性设置为Strech.
3.导入命名空间以便可以绘制二维图形:
using System.Drawing.Drawing2D;
4.为窗体加载事件添加如下代码:
private void Form1_Load(object sender, EventArgs e)
{
this.Left = (SystemInformation.PrimaryMonitorMaximizedWindowSize.Width - this.Width) / 2;
this.Top = (SystemInformation.PrimaryMonitorMaximizedWindowSize.Height - this.Height) / 2;
}
5.同时为Paint事件添加如下代码:
private void Form1_Paint(object sender, PaintEventArgs e)
{
GraphicsPath Myformpath = new GraphicsPath();
Myformpath.AddEllipse(0,0,this.Width-30,this.Height-30);
this.Region = new Region(Myformpath);
}
6.最后为窗体的DoubleClick事件添加如下代码,以便双击可以退出程序:
private void Form1_DoubleClick(object sender, EventArgs e)
{
Application.Exit();
}