最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

嘉荫县| 夹江县| 车致| 德化县| 托克逊县| 上饶市| 潞西市| 梁山县| 巴彦淖尔市| 宁河县| 泰兴市| 常宁市| 尉犁县| 静安区| 上杭县| 会同县| 逊克县| 衡阳县| 保亭| 禹城市| 彝良县| 濮阳县| 昭觉县| 邮箱| 新乐市| 富锦市| 陕西省| 民和| 西畴县| 翁源县| 弋阳县| 依安县| 福海县| 沾化县| 富宁县| 射洪县| 呈贡县| 滨州市| 富锦市| 峨眉山市| 曲周县|