您的位置:首页 > 其它

Winform窗体实现类似停靠在屏幕边缘时自动隐藏的功能

2009-08-01 16:02 696 查看
该功能主要用到了计时器和Frm_LocationChanged事件。代码如下;

private void FrmLocation_Load(object sender, EventArgs e)

private void StopRectTimer_Tick(object sender, EventArgs e)

private void FrmLocation_LocationChanged(object sender, EventArgs e)
{
if (this.Top <= 0)
{
this.StopDock = AnchorStyles.Top;
}
else if (this.Bottom >= Screen.PrimaryScreen.Bounds.Height)
{
this.StopDock = AnchorStyles.Bottom;
}
else if (this.Left <= 0)
{
this.StopDock = AnchorStyles.Left;
}
else if (this.Left >= Screen.PrimaryScreen.Bounds.Width - this.Width)
{
this.StopDock = AnchorStyles.Right;
}
else
{
this.StopDock = AnchorStyles.None;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: