国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

c# 實現窗體拖到屏幕邊緣自動隱藏

2020-01-24 03:46:48
字體:
來源:轉載
供稿:網友
以下給出源代碼: (注:hide為窗體名稱)
復制代碼 代碼如下:

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();
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 革吉县| 黑龙江省| 左贡县| 盐池县| 保定市| 城步| 枞阳县| 南岸区| 罗山县| 尚志市| 四平市| 金平| 南部县| 百色市| 蕉岭县| 容城县| 察雅县| 湘乡市| 晋州市| 乌鲁木齐市| 湖口县| 耿马| 渭南市| 留坝县| 峨眉山市| 乌兰浩特市| 佛坪县| 甘洛县| 谢通门县| 万全县| 金塔县| 揭阳市| 通州市| 盐津县| 杭州市| 礼泉县| 施甸县| 彭山县| 岳阳县| 泰顺县| 宜兴市|