public
Created

MoveWindow to screen

  • Download Gist
gistfile1.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12
var lastScreen = this.GetScreenFromRect(lastRect);
var newScreen = this.GetScreenFromRect(newRect);
if (!lastScreen.Bounds.Equals(newScreen.Bounds))
{
var x = (newRect.Left - newScreen.Bounds.X) + lastScreen.Bounds.X;
var y = (newRect.Top - newScreen.Bounds.Y) + lastScreen.Bounds.Y;
var width = newRect.Right - newRect.Left;
var height = newRect.Bottom - newRect.Top;
 
Window32API.MoveWindow(this.hWnd, x, y, width, height, false);
}
this.Activate();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.