做了一个控件,这样就可以告别
图片按钮了:)
程序源代码:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
namespace WindowsControlLibrary1
{
/// <summary>
/// UserControl1 的摘要说明。
/// </summary>
public class UserControl1 : Button
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private bool XiaCen=false;
private bool mouseMove=false;
private Color backColor;
public UserControl1()
{
// 该调用是 Windows.Forms 窗体设计器所必需的。
InitializeComponent();
// TODO: 在 InitComponent 调用后添加任何初始化
backColor=this.backColor;
//this.Text=this.ShowFocusCues.ToString();
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
//
// UserControl1
//
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.UserControl1_MouseUp);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.UserControl1_Paint);
this.MouseEnter += new System.EventHandler(this.UserControl1_MouseEnter);
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UserControl1_KeyUp);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.UserControl1_KeyDown);
this.BackColorChanged += new System.EventHandler(this.UserControl1_BackColorChanged);
this.MouseLeave += new System.EventHandler(this.UserControl1_MouseLeave);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.UserControl1_MouseDown);
}
#endregion
protected GraphicsPath GetGraphicsPath(Rectangle rect)
{
GraphicsPath ClientPath = new System.Drawing.Drawing2D.GraphicsPath();
if(rect.Width<=0)
{
rect.Width=1;
}
if(rect.Height<=0)
{
rect.Height=1;
&nbs