Fix rcNormalPosition in SetWindowPlacement

This commit is contained in:
Bret Anderson 2019-10-14 12:17:55 -07:00
parent f254afbd00
commit 03cb04823c
2 changed files with 6 additions and 5 deletions

View File

@ -1,6 +1,5 @@
#include "pch.h"
struct Zone : winrt::implements<Zone, IZone>
{
public:
@ -75,6 +74,12 @@ void Zone::SizeWindowToZone(HWND window, HWND zoneWindow) noexcept
// Map to screen coords
MapWindowRect(zoneWindow, nullptr, &zoneRect);
MONITORINFO mi{sizeof(mi)};
if (GetMonitorInfoW(MonitorFromWindow(zoneWindow, MONITOR_DEFAULTTONEAREST), &mi))
{
OffsetRect(&zoneRect, mi.rcMonitor.left - mi.rcWork.left, mi.rcMonitor.top - mi.rcWork.top);
}
WINDOWPLACEMENT placement;
::GetWindowPlacement(window, &placement);
placement.rcNormalPosition = zoneRect;

View File

@ -270,10 +270,6 @@ IFACEMETHODIMP_(void) ZoneSet::MoveSizeEnd(HWND window, HWND zoneWindow, POINT p
if (auto zone = ZoneFromPoint(ptClient))
{
zone->AddWindowToZone(window, zoneWindow, true);
POINT pointAdjustedScreen = ptClient;
MapWindowPoints(zoneWindow, nullptr, &pointAdjustedScreen, 1);
SetCursorPos(pointAdjustedScreen.x, pointAdjustedScreen.y);
}
}