Hi !
Ive been wrapping GetWindowPlacement function of the Win32 API.
The function call succeeds and returns != 0 and the showCmd member looks
correct.
The problem is that all coordinates in the RECT (rcNormalPosition) are 0
when the functions returns.
It all looks like this:
[DllImport("user32.dll")]
public static extern int GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT
lpwndpl);
With a RECT struct like this:
[Serializable, StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
and a POINT struct like this:
[Serializable, StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public long x;
public long y;
}
The call looks like this:
WINDOWPLACEMENT winP = new WINDOWPLACEMENT();
winP.length = (uint)Marshal.SizeOf(winP);
int succes = GetWindowPlacement(props.Hwnd, ref winP);
Cant figure out why i dont get the coordinates in the rect struct, they are
all set to 0, when the function has returned.
Im calling with top lvl window handles of visible windows.
Any ideas ???
Much appreciated.
Best regards Thue Tuxen
Mattias Sjögren - 20 Apr 2006 20:13 GMT
>and a POINT struct like this:
>[Serializable, StructLayout(LayoutKind.Sequential)]
[quoted text clipped - 3 lines]
> public long y;
>}
The POINT members should be ints, not longs.
Mattias

Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Thue Tuxen Sørensen - 20 Apr 2006 20:30 GMT
ohhhhhh thank you !
That fixed it, its working properly now.
:o)
> >and a POINT struct like this:
>>[Serializable, StructLayout(LayoutKind.Sequential)]
[quoted text clipped - 7 lines]
>
> Mattias