Having some annoying issues with API calls
Quite simply, trying to get the window size of another window. Quite easy research told me to use GetWindowRect (and subsequently GetClientRect for other stuff I want to do).
Code:
[DllImport("user32.dll")]
private static extern bool GetWindowRect(int hwnd, ref RECT Rect);
...
// down here somewhere I have successfully tracked the program window I want to look up (and in future affect) y = process from a list
int hWnd = y.Handle.ToInt32(); // works, I get the correct handle
RECT r = new RECT(); // created with blank/zero values
GetWindowRect(hWnd, out r);
// get to here and r is still a bunch of zero's...
...
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
// ignore the values as such, i've found several different ways of doing this, if you know a way that works, let me know!
public int X;
public int Y;
public int Width;
public int Height;
}
So I successfully track and locate the window I want to move, via a system of adding a program to a listview by it's full path, and then searching the processes for a match which works successfully. But it seems anything I try with API stuff (and not just GetWindowRect) just seems to do nothing. I would be grateful if someone could point out what's going wrong, or even give me a numpties crash course in API stuff...!