怎样能够让鼠标在窗体外点击,窗体自动关闭或隐藏?
解决方案 »
- C# winfrom 菜单太多一行放不开
- C#winform程序能反射获得数据提供程序工厂及使用缓存吗?
- 从其它窗体,向新new出的窗体中的datagridview控件加数据
- 新手求指导---不太懂这个例题
- 大家认为在winform中嵌入WPF控件这种开发形式如何?
- 200分求两个简单问题答案,有关FlowLayoutPanel
- 如何在一个表中快速添加主键?【表中已有数据】
- 将下列vb.net语句转化为C#.net
- web界面设计视图不显示服务器控件问题
- 关于鼠标点击到表格的一个单元格,如何获取该表格的那一行内容
- 高手速来接分, 1.575不进位 1.475进位, 1.275又不进位
- combobox中item的值的问题
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();
}
}
}
{
this.Close();// this.Visible = false;隐藏
}
已经测试,符合楼主要求。谢谢
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();
}
改进一下,可以实现鼠标移动位置
public Form1()
{
InitializeComponent();
this.Deactivate += new EventHandler(Form1_Deactivate);}
void Form1_Deactivate(object sender, EventArgs e)
{
this.Close();
//this.Hide();
}
{
this.Opacity = 0.5d;//这是透明
//this.Hide();
}
应该不用那么麻烦吧