1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Text; 7 using System.Windows.Forms; 8 9 namespace juxing 10 { 11 public partial class Form1 : Form 12 { 13 public Form1() 14 { 15 InitializeComponent(); 16 } 17 18 private void Form1_Load(object sender, EventArgs e) 19 { 20 button1.Visible = false; 21 } 22 23 private void Form1_MouseMove(object sender, MouseEventArgs e) 24 { 25 Point point= this.PointToScreen(new Point(e.X, e.Y)); 26 Rectangle rc = this.button1.RectangleToScreen(this.button1.ClientRectangle); 27 if (rc.Contains(point)) 28 { 29 button1.Visible = true; 30 } 31 else 32 { 33 button1.Visible = false; 34 } 35 } 36 } 37 }