首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

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

2012-06-20 
怎样能够让鼠标在窗体外点击,窗体自动关闭或隐藏?怎样能够让鼠标在窗体外点击,窗体自动关闭或隐藏?[解决办

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

[解决办法]

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();        } 

热点排行