首页 新闻 搜索 专区 学院

仿QQ贴边隐藏窗体点击最小化后无法恢复窗体??

0
悬赏园豆:20 [已关闭问题] 关闭于 2012-03-13 16:01

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
Timer StopRectTimer
= new Timer();
StopRectTimer.Tick
+= new EventHandler(timer1_Tick);
StopRectTimer.Interval
= 100;
StopRectTimer.Enabled
= true;
}

internal AnchorStyles StopAanhor = AnchorStyles.None;

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;
}
}
}

private void mStopAnthor()
{
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 Form1_LocationChanged(object sender, EventArgs e)
{
this.mStopAnthor();
}
}
希望能帮忙 就是最小化窗体后 没办法恢复!!!

youngkeen的主页 youngkeen | 初学一级 | 园豆:8
提问于:2011-03-18 23:31
< >
分享
所有回答(1)
0

可参考:

http://topic.csdn.net/u/20090713/16/7cffc498-127d-45f8-a89a-f76bad6e9f35.html

http://www.delphifans.com/infoview/Article_453.html

winzheng | 园豆:8797 (大侠五级) | 2011-03-19 13:36
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册