`

C#实现窗口在右下角不越界

阅读更多

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

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics