像qq一样停靠.txt

来自「非常好的.net学习经验记录」· 文本 代码 · 共 50 行

TXT
50
字号
	private void timer1_Tick(object sender, EventArgs e) 
		{
			if (this.WindowState != System.Windows.Forms.FormWindowState.Minimized) 
			{
				if (Cursor.Position.X > this.Left && Cursor.Position.X < this.Right && Cursor.Position.Y > this.Top && Cursor.Position.Y < this.Bottom) 
				{
					if (this.Top < 0) 
					{
						this.Top = -5;
						this.Show();
					} 
					else if (this.Left < 0) 
					{
						this.Left = -5;
						this.Show();
					} 
					else if (this.Left + this.Width >= Screen.PrimaryScreen.WorkingArea.Width) 
					{
						this.Left = Screen.PrimaryScreen.WorkingArea.Width - this.Width + 5;
						this.Show();
					}
				} 
				else 
				{
					/******************变化处******************/
					if (this.Top <= 4) 
					{
						this.Top = 5 - this.Height;
						if (this.Left <= 4) 
						{
							this.Left =-5;
						} 
						else if (this.Left + this.Width >= Screen.PrimaryScreen.WorkingArea.Width - 4) 
						{
							this.Left = Screen.PrimaryScreen.WorkingArea.Width - this.Width + 5;
						}
						/******************变化处******************/
					} 
					else if (this.Left <= 4) 
					{
						this.Left = 5 - this.Width;
					} 
					else if (this.Left + this.Width >= Screen.PrimaryScreen.WorkingArea.Width - 4) 
					{
						this.Left = Screen.PrimaryScreen.WorkingArea.Width - 5;
					}
				}
			}
		}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?