我想实现一个拖到窗口上方自动隐藏,和鼠标放上去自动显示的功能
是这样的,我在mousemove 里判断 if( Top ==0)
this.Top = this.Top - this.Height + 5; 让他缩到上方,这样的话,如何才能够让他再次显示出来啊
我在mouseenter里 if (this.Top < 0)
{
ResizeToOrginal(); //还原成初始大小
}这样就会出现死循环请大家提点一下~嘿嘿,还有怎么把贴出来的代码像其他人那样比较整齐的,带有c# code这样的?
是这样的,我在mousemove 里判断 if( Top ==0)
this.Top = this.Top - this.Height + 5; 让他缩到上方,这样的话,如何才能够让他再次显示出来啊
我在mouseenter里 if (this.Top < 0)
{
ResizeToOrginal(); //还原成初始大小
}这样就会出现死循环请大家提点一下~嘿嘿,还有怎么把贴出来的代码像其他人那样比较整齐的,带有c# code这样的?
解决方案 »
- -----关于 winform 的 Application.Restart() 问题,求解!
- 求一正则表达式,在等等,急用呀
- DataGrid 中增加新的行
- 在vs.net下伪造源页面是不是这样写的? HttpWebRequest HWR = null;HWR.Referer = @"http://club.gzxxx.cn/";
- 如何实现象MSN那样敲enter发送,而在文本中并没有回车符
- 请问WinForm中的DataGrid如何实现 增加,修改,删除功能?
- 急聘系统设计人员一名(兼职),诚聘各位星级人物。
- 简单的属性知识
- 请问如何通过表达式选取泛型集合中的某个实体属性
- TextBox
- 错误提示 当前上下文中不存在名称“conn” 代码如下
- GetProcAddress找不到指定的程序
this.Top = this.Top - this.Height + 5;
这样设置的话,窗体居然完全消失了,没辙~
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
int OrgHeight = 0;
Timer T = new Timer(); public Form1()
{
InitializeComponent(); OrgHeight = this.Height;
this.LocationChanged += new EventHandler(Form1_LocationChanged);
this.MouseEnter += new EventHandler(Form1_MouseEnter);
T.Interval = 100;
T.Tick += new EventHandler(T_Tick);
} void T_Tick(object sender, EventArgs e)
{
if (!this.Bounds.Contains(Control.MousePosition) && this.Top == 0)
{
HideForm();
T.Enabled = false;
}
} void Form1_MouseEnter(object sender, EventArgs e)
{
if (this.FormBorderStyle == FormBorderStyle.None)
{
this.FormBorderStyle = FormBorderStyle.Sizable;
this.Height = OrgHeight;
T.Enabled = true;
}
} void Form1_LocationChanged(object sender, EventArgs e)
{
if (this.Top <= 0)
{
HideForm();
T.Enabled = false;
}
} private void HideForm()
{
this.Top = 0;
this.FormBorderStyle = FormBorderStyle.None;
this.Height = 1;
}
}
}