Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / April 2006

Tip: Looking for answers? Try searching our database.

GetWindowPlacement problem. RECT members are all zeroes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thue Tuxen Sørensen - 20 Apr 2006 17:29 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.