I am trying to position a window to the corner of my screen. Top left corner, top right corner etc. Currently I am using the MoveWindow function below to move the screen.
[DllImport("user32.dll", SetLastError = true)]
static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int Width, int Height, bool Repaint);
This works however, I can't seem to find any function that reports the working area of my monitor correctly. There is always this margin that doesn't seem to get included in the position.
If I open a notepad and snap it to the left corner the top left position is -8, -8, not 0, 0, as you would think it would be.
Screen.PrimaryScreen.WorkingArea
reports 0,0.
IntPtr hWndDesktop = GetDesktopWindow();
RECT desktopRectangle = new RECT();
GetWindowRect(hWndDesktop, out desktopRectangle);
reports 0,0.
Screen.PrimaryScreen.Bounds
reports 0,0.
Since all these functions report 0,0, every time I move the window to that position, there is a gap between the corner of the desktop in the x and y position.
The only solution that I can seem to think of, that might work is to maximize an invisible window, and get the x,y, width, and height of it, and then use that, however it seems a bit hackish. I guess I could also - the margin value (8), but I am assuming that value won't be the same for every screen.