Everything is working.

This commit is contained in:
Bret Anderson
2019-09-15 13:34:00 -07:00
parent d4c8c84445
commit c0cdf7aaa6
6 changed files with 41 additions and 29 deletions

View File

@@ -1,5 +1,6 @@
#include "pch.h"
#include <common/settings_objects.h>
#include <common/dpi_aware.h>
#include <interface/powertoy_module_interface.h>
#include <interface/lowlevel_keyboard_event_data.h>
#include <interface/win_hook_event_data.h>
@@ -27,29 +28,18 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser
return TRUE;
}
// TODO: multimon support, need to pass the HMONITOR from the editor to here instead
// of using MonitorFromPoint
// This function is exported and called from FancyZonesEditor.exe to save a layout from the editor.
STDAPI PersistZoneSet(
PCWSTR activeKey, // Registry key holding ActiveZoneSet
PCWSTR resolutionKey, // Registry key to persist ZoneSet to
HMONITOR monitor,
WORD layoutId, // LayoutModel Id
int zoneCount, // Number of zones in zones
int zones[]) // Array of zones serialized in left/top/right/bottom chunks
{
// See if we have already persisted this layout we can update.
std::wstringstream stream;
MONITORINFOEX mi;
mi.cbSize = sizeof(mi);
if (GetMonitorInfo(monitor, &mi))
{
stream << (mi.rcMonitor.right - mi.rcMonitor.left) << "_";
stream << (mi.rcMonitor.bottom - mi.rcMonitor.top);
}
std::wstring resolutionKey(stream.str());
UUID id{GUID_NULL};
if (wil::unique_hkey key{ RegistryHelpers::OpenKey(resolutionKey.c_str()) })
if (wil::unique_hkey key{ RegistryHelpers::OpenKey(resolutionKey) })
{
ZoneSetPersistedData data{};
DWORD dataSize = sizeof(data);
@@ -84,7 +74,7 @@ STDAPI PersistZoneSet(
id,
layoutId,
reinterpret_cast<HMONITOR>(monitor),
resolutionKey.c_str(),
resolutionKey,
ZoneSetLayout::Custom,
0, 0, 0));