using System;
using System.Drawing;
using System.Windows.Forms;
public class MouseEnterHoverLeave : Form
{
private Button btn;
string str = "";
public MouseEnterHoverLeave()
{
Size = new Size(400,400);
btn = new Button();
btn.Parent = this;
btn.Location = new Point(50,50);
btn.Size = new Size(150,25);
btn.MouseEnter += new System.EventHandler(btn_MouseEnter);
btn.MouseHover += new System.EventHandler(btn_MouseHover);
btn.MouseLeave += new System.EventHandler(btn_MouseLeave);
}
static void Main()
{
Application.Run(new MouseEnterHoverLeave());
}
private void btn_MouseEnter(object sender, EventArgs e)
{
btn.Text = "MouseEnter";
}
private void btn_MouseHover(object sender, EventArgs e)
{
btn.Text = "MouseHover";
}
private void btn_MouseLeave(object sender, EventArgs e)
{
btn.Text = "MouseLeave";
}
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter(e);
Console.WriteLine("Form MouseEnter");
}
protected override void OnMouseHover(EventArgs e)
{
base.OnMouseHover(e);
Console.WriteLine("Form MouseHover");
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
Console.WriteLine("Form MouseLeave");
}
}
|