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

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

 更新時間:2009年02月14日 14:31:02   作者:  
讓窗體拖到屏幕邊緣自動隱藏的原理,通過Form1_LocationChanged的方法,當(dāng)窗體位置發(fā)生改變時,判斷其是否在屏幕邊緣,在則隱藏。再通過Timer控件經(jīng)過指定時間判斷出鼠標(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)文章

最新評論

鸡东县| 田阳县| 广河县| 隆尧县| 彰武县| 武夷山市| 临潭县| 梁河县| 班戈县| 黄浦区| 乌什县| 胶州市| 奇台县| 固始县| 镇江市| 乌兰浩特市| 阳江市| 延庆县| 赣榆县| 益阳市| 山阳县| 册亨县| 仪征市| 辉县市| 清流县| 炉霍县| 新安县| 铜陵市| 汪清县| 油尖旺区| 乌拉特中旗| 岳阳县| 洪泽县| 河北省| 榕江县| 双辽市| 湾仔区| 宁远县| 崇礼县| 临颍县| 揭东县|