日期:2014-05-18 浏览次数:21214 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication291
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Timer T = new Timer();
T.Interval = 100;
T.Tick += new EventHandler(T_Tick);
T.Enabled = true;
}
void T_Tick(object sender, EventArgs e)
{
if (!this.Bounds.Contains(Control.MousePosition)
&&Control.MouseButtons==MouseButtons.Left )
Close();
}
}
}
------解决方案--------------------
public Form4()
{
InitializeComponent();
Timer T = new Timer();
T.Interval = 100;
T.Tick += new EventHandler(T_Tick);
T.Enabled = true;
}
void T_Tick(object sender, EventArgs e)
{
if (!this.Bounds.Contains(Control.MousePosition))
Text = Control.MousePosition.X.ToString();
//Close();
}