C# 模仿QQ靠近边缘自动隐藏 求这段代码最好能给个说明或者注释·· 就是当窗体靠近windows窗体时候自动隐藏上去··估计大家都见过吧 就和QQ一样·· 希望给个代码 最好短点的·加说明的谢谢·· 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我也想知道,期待大虾们的答案ing。呵呵 取鼠标move事件. 判断. 当坐标点x,或者y 一旦有个到了0 就可以将他的大小改成0,1 当鼠标移到他上面的时候.就把他大小还原. 中间建两个变量存储他的状态和.原大小.. 不知道这么说 行不.. 我在北大青鸟做项目的时候也用到了 我把代码给你了 我们过几天项目答辩了!~ private void timFormBerth_Tick(object sender, EventArgs e) //窗口停靠伸缩算法 { if (WindowState != FormWindowState.Minimized) { int ScreenWidth = Screen.PrimaryScreen.WorkingArea.Width; //屏幕宽度 int ScreenRight = Screen.PrimaryScreen.WorkingArea.Right; //屏幕高度 int MouseX = Control.MousePosition.X; //鼠标X位置 int MouseY = Control.MousePosition.Y;//鼠标垂直位置 if (this.Left < 0 && this.Top < 0) { this.Left = 0; this.Top = 1; } if (this.Left >= ScreenWidth - this.Right && this.Top < 0) //如果自己的左边是否在屏幕的边缘 { this.Left = ScreenWidth; this.Top = 0; } if (this.Top < 0 && MouseX > this.Left && MouseX < this.Left + this.Width && MouseY < 3) { this.Top = 0; } if (this.Top <= 0 && this.Left > 0 && this.Left < ScreenWidth - this.Width) { if (MouseX < this.Left || MouseX > this.Left + this.Width || MouseY > this.Top + this.Right) { this.Top = 3 - this.Right; } } if (this.Left < 0 && MouseY > this.Top && MouseY < this.Top + this.Width && MouseX < 3) { this.Left = 0; } if (this.Left <= 0 && this.Top > 0 && this.Top < ScreenRight - this.Right) { if (MouseY < this.Top || MouseY > this.Top + this.Right || MouseX > this.Width) { this.Left = 3 - this.Width; } } if (this.Left >= ScreenWidth - this.Width && this.Top > 0 && this.Top < ScreenRight - this.Width) { if (MouseY < this.Top || MouseY > this.Top + this.Right || MouseX < ScreenWidth - this.Width) { this.Left = ScreenWidth - 3; } } if (this.Left > ScreenWidth - 5) //判断自己的左边是否隐藏了 { if (MouseX > ScreenWidth - 5) //如果隐藏了 判断鼠标是不在屏幕的边缘 { this.Left = ScreenWidth - this.Width; } } } } 仓库任务管理实现问题 windowserver LISTVIEW 加亮显示 VSS出现问题了! C++中的int *p 类型在C#中用什么类型转换啊? ado.net数据库连接字符串问题 大家进来看看这个关于界面的问题 window如何才能被单击事件拖动? 求助,怎么解决下面两个难点! 请问Debug目录下和 Release目录下生成的EXE文件有何实质性区别 C#中调用API关机函数,不执行的问题!!!!! 我在桌面编程时想实现多线程解决窗体假死状态
判断. 当坐标点x,或者y 一旦有个到了0
就可以将他的大小改成0,1
当鼠标移到他上面的时候.就把他大小还原.
中间建两个变量存储他的状态和.原大小..
不知道这么说 行不..
~
private void timFormBerth_Tick(object sender, EventArgs e) //窗口停靠伸缩算法
{
if (WindowState != FormWindowState.Minimized)
{
int ScreenWidth = Screen.PrimaryScreen.WorkingArea.Width; //屏幕宽度
int ScreenRight = Screen.PrimaryScreen.WorkingArea.Right; //屏幕高度
int MouseX = Control.MousePosition.X; //鼠标X位置
int MouseY = Control.MousePosition.Y;//鼠标垂直位置
if (this.Left < 0 && this.Top < 0)
{
this.Left = 0;
this.Top = 1;
}
if (this.Left >= ScreenWidth - this.Right && this.Top < 0) //如果自己的左边是否在屏幕的边缘
{
this.Left = ScreenWidth;
this.Top = 0;
}
if (this.Top < 0 && MouseX > this.Left && MouseX < this.Left + this.Width && MouseY < 3)
{
this.Top = 0;
}
if (this.Top <= 0 && this.Left > 0 && this.Left < ScreenWidth - this.Width)
{
if (MouseX < this.Left || MouseX > this.Left + this.Width || MouseY > this.Top + this.Right)
{
this.Top = 3 - this.Right;
}
}
if (this.Left < 0 && MouseY > this.Top && MouseY < this.Top + this.Width && MouseX < 3)
{
this.Left = 0;
}
if (this.Left <= 0 && this.Top > 0 && this.Top < ScreenRight - this.Right)
{
if (MouseY < this.Top || MouseY > this.Top + this.Right || MouseX > this.Width)
{
this.Left = 3 - this.Width;
}
}
if (this.Left >= ScreenWidth - this.Width && this.Top > 0 && this.Top < ScreenRight - this.Width)
{
if (MouseY < this.Top || MouseY > this.Top + this.Right || MouseX < ScreenWidth - this.Width)
{
this.Left = ScreenWidth - 3;
}
} if (this.Left > ScreenWidth - 5) //判断自己的左边是否隐藏了
{
if (MouseX > ScreenWidth - 5) //如果隐藏了 判断鼠标是不在屏幕的边缘
{
this.Left = ScreenWidth - this.Width;
}
}
} }