You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tested on Windows 10 Pro 21H2 x64 using Vanara 3.4.14 from NuGet.
Vanara's WINDOWPLACEMENT structure includes the rcDevice field which is only defined in WinUser.h on Mac platforms, causing the size of the structure to be incorrect and SetWindowPlacement to fail.
From WinUser.h:
typedef struct tagWINDOWPLACEMENT {
UINT length;
UINT flags;
UINT showCmd;
POINT ptMinPosition;
POINT ptMaxPosition;
RECT rcNormalPosition;
#ifdef _MAC
RECT rcDevice;
#endif
} WINDOWPLACEMENT;
What code is involved
Initialize a Vanara.PInvoke.User32.WINDOWPLACEMENT structure with the length field set using (uint)Marshal.SizeOf(windowPlacement) (which returns 60) and use it in a call to Vanara.PInvoke.User32.SetWindowPlacement. The call returns false and GetLastError returns ERROR_INVALID_PARAMETER.
If you instead set length manually to 44 (the size of the WINDOWPLACEMENT structure without the rcDevice field), the call is successful and works as expected.
GetWindowPlacement returns a structure with the length set to 44.
Expected behavior
The call to SetWindowPlacement should succeed.
The text was updated successfully, but these errors were encountered:
Describe the bug and how to reproduce
Tested on Windows 10 Pro 21H2 x64 using Vanara 3.4.14 from NuGet.
Vanara's
WINDOWPLACEMENT
structure includes thercDevice
field which is only defined inWinUser.h
on Mac platforms, causing the size of the structure to be incorrect andSetWindowPlacement
to fail.From
WinUser.h
:What code is involved
Initialize a
Vanara.PInvoke.User32.WINDOWPLACEMENT
structure with thelength
field set using(uint)Marshal.SizeOf(windowPlacement)
(which returns 60) and use it in a call toVanara.PInvoke.User32.SetWindowPlacement
. The call returnsfalse
andGetLastError
returnsERROR_INVALID_PARAMETER
.If you instead set
length
manually to 44 (the size of theWINDOWPLACEMENT
structure without thercDevice
field), the call is successful and works as expected.GetWindowPlacement
returns a structure with thelength
set to 44.Expected behavior
The call to
SetWindowPlacement
should succeed.The text was updated successfully, but these errors were encountered: