using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;namespace TooltipDemo { public partial class TipsForm : Form { Form Mainform; int state; int move; public TipsForm(Form mainform) { Mainform = mainform; move = 1; this.TopMost = true; InitializeComponent(); } private void TipsForm_Load(object sender, EventArgs e) { this.Left = Screen.PrimaryScreen.WorkingArea.Width - this.Width; this.Top = 0; state = 0; } private void TipsForm_MouseEnter(object sender, EventArgs e) { if (move == 1) { if (state == 0) { state = 1; int t = this.Top; for (int i = t; i <= 0; i++) { this.Top = i; Application.DoEvents(); } state = 0; } } } private void TipsForm_MouseLeave(object sender, EventArgs e) { if (move == 1) { if (this.Top <= 0 && state == 0) { state = 1; int t = this.Top; for (int i = t; i > -this.Height + 5; i--) { this.Top = i; Application.DoEvents(); } state = 0; } } }
参考:
http://blog.csdn.net/yhy0611/archive/2009/01/09/3738550.aspx
http://sourceforge.net/projects/dockpanelsuite/
(dream_ice) 等 级:
结帖率:101.41% 你的结贴率真牛.....
类似2005?类似2005的哪个?得看你想实现什么样的隐藏效果了。
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace TooltipDemo
{
public partial class TipsForm : Form
{
Form Mainform;
int state;
int move;
public TipsForm(Form mainform)
{
Mainform = mainform;
move = 1;
this.TopMost = true;
InitializeComponent();
} private void TipsForm_Load(object sender, EventArgs e)
{
this.Left = Screen.PrimaryScreen.WorkingArea.Width - this.Width;
this.Top = 0;
state = 0; } private void TipsForm_MouseEnter(object sender, EventArgs e)
{
if (move == 1)
{
if (state == 0)
{
state = 1;
int t = this.Top;
for (int i = t; i <= 0; i++)
{
this.Top = i;
Application.DoEvents();
}
state = 0;
}
} } private void TipsForm_MouseLeave(object sender, EventArgs e)
{
if (move == 1)
{
if (this.Top <= 0 && state == 0)
{
state = 1;
int t = this.Top;
for (int i = t; i > -this.Height + 5; i--)
{
this.Top = i;
Application.DoEvents();
}
state = 0;
}
}
}
private void TipsForm_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (move == 1) move = 0;
else move = 1;
}
}
}
给lz个算法 我前几天用过 效果跟QQ一样 窗体在右上角 鼠标移动过去会移动隐藏 双击窗体可以固定窗体