模仿QQ主窗体自动收缩的功能,展示部分功能。
private void Timer1_Tick(object sender, EventArgs e)
{
if (Top < 3 && Tem_place == 0)//如果窗体被移到屏幕的顶部
{
if (Handle == FormNameAt(Cursor.Position.X, Cursor.Position.Y))//当鼠标移致到该窗体上
{
panel_Title.Tag = 1;//设置标识,用于判断窗体在屏幕顶部
timer2.Enabled = false;//不对窗体进行拉伸操作
Top = 0;//使窗体致顶
}
else
{
panel_Title.Tag = 1;//设置标识,用于判断窗体在屏幕顶部
timer2.Enabled = true;//将窗体在顶部进行隐藏
}
}
else
{
if (Left < 3 || Right > GetSystemMetrics(0) - 3)//如果窗体被移到屏幕的左端或右端
{
if (Left < 3)//如果窗体被移到屏幕的左端
{
if (Handle == FormNameAt(Cursor.Position.X, Cursor.Position.Y))//当鼠标移致到该窗体上
{
panel_Title.Tag = 2;//设置标识,用于判断窗体在屏幕左端
timer2.Enabled = false;
Frm_Height = Height;
Left = 0;//使窗体致左
Top = 0;
Height = Screen.AllScreens[0].Bounds.Height;
Tem_place = 1;
}
else
{
panel_Title.Tag = 2;
timer2.Enabled = true;//将窗体在左端进行隐藏
}
}
if (Right > GetSystemMetrics(0) - 3)//如果窗体被移到屏幕的右端
{
if (Handle == FormNameAt(Cursor.Position.X, Cursor.Position.Y))//当鼠标移致到该窗体上
{
panel_Title.Tag = 3;//设置标识,用于判断窗体在屏幕右端
timer2.Enabled = false;
Frm_Height = Height;
Left = GetSystemMetrics(0) - Width;//使窗体致右
Top = 0;
Height = Screen.AllScreens[0].Bounds.Height;
Tem_place = 1;
}
else
{
panel_Title.Tag = 3;
timer2.Enabled = true;//将窗体在右端进行隐藏
}
}
}
}
}