2 out of 6 rated this helpful Rate this topic

GetWindowPlacement function

Retrieves the show state and the restored, minimized, and maximized positions of the specified window.

Syntax

BOOL WINAPI GetWindowPlacement(
  __in     HWND hWnd,
  __inout  WINDOWPLACEMENT *lpwndpl
);

Parameters

hWnd [in]

Type: HWND

A handle to the window.

lpwndpl [in, out]

Type: WINDOWPLACEMENT*

A pointer to the WINDOWPLACEMENT structure that receives the show state and position information. Before calling GetWindowPlacement, set the length member to sizeof(WINDOWPLACEMENT). GetWindowPlacement fails if lpwndpl-> length is not set correctly.

Return value

Type: BOOL

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The flags member of WINDOWPLACEMENT retrieved by this function is always zero. If the window identified by the hWnd parameter is maximized, the showCmd member is SW_SHOWMAXIMIZED. If the window is minimized, showCmd is SW_SHOWMINIMIZED. Otherwise, it is SW_SHOWNORMAL.

The length member of WINDOWPLACEMENT must be set to sizeof(WINDOWPLACEMENT). If this member is not set correctly, the function returns FALSE. For additional remarks on the proper use of window placement coordinates, see WINDOWPLACEMENT.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Reference
SetWindowPlacement
WINDOWPLACEMENT
Conceptual
Windows

 

 

Send comments about this topic to Microsoft

Build date: 9/11/2011

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
POINT structure has to be made up of ints

This one gave me quite a headache.

According to documentation the POINT structure within the WINDOWPLACEMENT one should have two long values for x and y.
If you use that, GetWindowPlacement will yield false results (normalPosition empty) though.

After I changed POINT to be two ints everything works just fine.

The flags member
The flags member of the retrieved WINDOWPLACEMENT structure has WPF_RESTORETOMAXIMIZED set if the window is maximized or has been minimized from a maximized state (and will be maximized if restored).
The length member

The function works great on Windows NT systems without filling in the length value. The function will only fail on Windows 9x with a wrong length value.

Found out while looking for some time why my program didn't work on 9x ;)