I'm looking for a way to check to see that a window I am creating is visible and entirely on one monitor. I have seen too many programs do nasty things when they try to restore their position and the place no longer exists and I don't want 开发者_Python百科my program to be vulnerable to this.
How do I find the information on the actual layout of the monitors?
The Screen class contains a lot of functionality for this.
You should check for yourself if a form is outside the Bounds of the Screen, but this is pretty straightforward:
if (!Screen.GetWorkingArea(myWindow).Bounds.Contains(myWindow.Bounds)) {
// Adjust location
}
Just a small syntax correction, or perhaps an update in Visual Studio 2012:
if (!Screen.GetWorkingArea(myWindow).Contains(myWindow.Bounds))
{
//Adjust location
}
精彩评论