I'm experiencing the issue described here.
I use
private IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
switch (msg)
{
case 0x0024: // WM_GETMINMAXINFO
MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
// Adjust the maximized size and position
// to fit the work area of the correct monitor
// int MONITOR_DEFAULTTONEAREST = 0x00000002;
IntPtr monitor = MonitorFromWindow(hwnd, 0x00000002);
if (monitor != IntPtr.Zero)
{
MONITORINFO monitorInfo = new MONITORINFO();
GetMonitorInfo(monitor, monitorInfo);
RECT rcWorkArea = monitorInfo.rcWork;
RECT rcMonitorArea = monitorInfo.rcMonitor;
mmi.ptMaxPosition.X = Math.Abs(rcWorkArea.Left - rcMonitorArea.Left);
mmi.ptMaxPosition.Y = Math.Abs(rcWorkArea.Top - rcMonitorArea.Top);
mmi.ptMaxSize.X = Math.Abs(rcWorkArea.Right - rcWorkArea.Left);
mmi.ptMaxSize.Y = Math.Abs(rcWorkArea.Bottom - rcWorkArea.Top);
}
Marshal.StructureToPtr(mmi, lParam, true);
var mmiAfterUpdate = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO)); // values are updated
handled = true;
break;
}
return IntPtr.Zero;
}
And my window is with WindowStyle="None" and AllowsTransparency="True" I checked the update values by rereading and casting lparam and it really contains the updated ptMaxPositioen values (0, 0) instead of (-7, -7)
But I found that when I drag the maximized window (I put the mouse cursor a bit lower to be able to do it) the lparam comes in WindowProc with (-7, -7) again.
Is there any way to fix such a behavior?
User contributions licensed under CC BY-SA 3.0