亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

c# 實(shí)現(xiàn)窗體拖到屏幕邊緣自動(dòng)隱藏

 更新時(shí)間:2009年02月14日 14:31:02   作者:  
讓窗體拖到屏幕邊緣自動(dòng)隱藏的原理,通過Form1_LocationChanged的方法,當(dāng)窗體位置發(fā)生改變時(shí),判斷其是否在屏幕邊緣,在則隱藏。再通過Timer控件經(jīng)過指定時(shí)間判斷出鼠標(biāo)的位置,若鼠標(biāo)在屏幕左邊、上邊或右邊,這根據(jù)窗體的位置,調(diào)出窗體。
以下給出源代碼: (注:hide為窗體名稱)
復(fù)制代碼 代碼如下:

private void hide_Load(object sender, EventArgs e)
{
System.Windows.Forms.Timer StopRectTimer = new System.Windows.Forms.Timer();
StopRectTimer.Tick += new EventHandler(timer1_Tick);
StopRectTimer.Interval = 100;
StopRectTimer.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (this.Bounds.Contains(Cursor.Position))
{
switch (this.StopAanhor)
{
case AnchorStyles.Top:
this.Location = new Point(this.Location.X, 0);
break;
case AnchorStyles.Left:
this.Location = new Point(0, this.Location.Y);
break;
case AnchorStyles.Right:
this.Location = new Point(Screen.PrimaryScreen.Bounds.Width - this.Width, this.Location.Y);
break;
}
}
else
{
switch (this.StopAanhor)
{
case AnchorStyles.Top:
this.Location = new Point(this.Location.X, (this.Height - 2) * (-1));
break;
case AnchorStyles.Left:
this.Location = new Point((-1) * (this.Width - 2), this.Location.Y);
break;
case AnchorStyles.Right:
this.Location = new Point(Screen.PrimaryScreen.Bounds.Width - 2, this.Location.Y);
break;
}
}
}
internal AnchorStyles StopAanhor = AnchorStyles.None;
private void mStopAnhor()
{
if (this.Top <= 0)
{
StopAanhor = AnchorStyles.Top;
}
else if (this.Left <= 0)
{
StopAanhor = AnchorStyles.Left;
}
else if (this.Left >= Screen.PrimaryScreen.Bounds.Width - this.Width)
{
StopAanhor = AnchorStyles.Right;
}
else
{
StopAanhor = AnchorStyles.None;
}
}
private void hide_LocationChanged(object sender, EventArgs e)
{
this.mStopAnhor();
}

相關(guān)文章

最新評(píng)論