读书人

怎么能够让鼠标在窗体外点击窗体自动

发布时间: 2012-06-20 20:37:21 作者: rapoo

怎样能够让鼠标在窗体外点击,窗体自动关闭或隐藏?
怎样能够让鼠标在窗体外点击,窗体自动关闭或隐藏?

[解决办法]

C# code
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();        }    }}
[解决办法]
C# code
 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();        } 

读书人网 >C#

热点推荐