C#实现窗口在右下角不越界
发布日期:2021-05-07 10:36:22 浏览次数:18 分类:技术文章

本文共 515 字,大约阅读时间需要 1 分钟。

 

        private Point AdjustPosition(Point point, int height, int width)

        {

            Point pTemp = point;

            if (point.X + width > Screen.PrimaryScreen.WorkingArea.Width) pTemp.X = Screen.PrimaryScreen.WorkingArea.Width - width;

            if (point.Y + height > Screen.PrimaryScreen.WorkingArea.Height) pTemp.Y = Screen.PrimaryScreen.WorkingArea.Height - height;

            return pTemp;

        }

 

        private void  窗体名称_LocationChanged(object sender, EventArgs e)

        {

                p = this.Location;

                this.PointToScreen(p);

                this.Location = AdjustPosition(p, this.Height, this.Width);        

        }

 

上一篇:C#实现窗口从屏幕右下角升起效果
下一篇:用C#完成类似于OFFICE中查找/替换中的高级选项效果

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2025年04月15日 11时55分46秒