You used the wrong structure Rectangle
in the GetWindowRect
function, you have to use the RECT
structure which can be defined like this:
public struct RECT {
public int left, top, right, bottom;
}
However, to get the Screen
in which the window has the most intersection, you can try using the static method Screen.FromControl
:
Screen scr = Screen.FromControl(yourForm);