diff --git a/idd/LGIddHelper/LGIddHelper.vcxproj b/idd/LGIddHelper/LGIddHelper.vcxproj index 35dad7ac..7a676a35 100644 --- a/idd/LGIddHelper/LGIddHelper.vcxproj +++ b/idd/LGIddHelper/LGIddHelper.vcxproj @@ -187,6 +187,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd + diff --git a/idd/LGIddHelper/LGIddHelper.vcxproj.filters b/idd/LGIddHelper/LGIddHelper.vcxproj.filters index 899737ac..ab4eea1f 100644 --- a/idd/LGIddHelper/LGIddHelper.vcxproj.filters +++ b/idd/LGIddHelper/LGIddHelper.vcxproj.filters @@ -43,6 +43,9 @@ Source Files + + Source Files + diff --git a/idd/LGIddHelper/UIHelpers.cpp b/idd/LGIddHelper/UIHelpers.cpp new file mode 100644 index 00000000..90e12929 --- /dev/null +++ b/idd/LGIddHelper/UIHelpers.cpp @@ -0,0 +1,17 @@ +#include "UIHelpers.h" +#include + +WidgetPositioner::~WidgetPositioner() +{ + if (!EndDeferWindowPos(hdwp)) + DEBUG_ERROR_HR(GetLastError(), "EndDeferWindowPos"); +} + +void WidgetPositioner::move(HWND child, int x, int y, int cx, int cy) +{ + HDWP next = DeferWindowPos(hdwp, child, nullptr, x, y, cx, cy, SWP_NOACTIVATE | SWP_NOZORDER); + if (next) + hdwp = next; + else + DEBUG_ERROR_HR(GetLastError(), "DeferWindowPos"); +} diff --git a/idd/LGIddHelper/UIHelpers.h b/idd/LGIddHelper/UIHelpers.h index 548be834..86865e63 100644 --- a/idd/LGIddHelper/UIHelpers.h +++ b/idd/LGIddHelper/UIHelpers.h @@ -1,4 +1,5 @@ #pragma once +#include #include struct FontTraits @@ -13,19 +14,16 @@ class WidgetPositioner HDWP hdwp; double m_scale; DWORD width, height; - inline int scale(int value) { return (int)round(value * m_scale); } + inline int scale(int value) { return (int)std::round(value * m_scale); } public: WidgetPositioner(double scale, DWORD width, DWORD height) : m_scale(scale), width(width), height(height), hdwp(BeginDeferWindowPos(10)) {} - ~WidgetPositioner() { EndDeferWindowPos(hdwp); } + ~WidgetPositioner(); - void move(HWND child, int x, int y, int cx, int cy) - { - hdwp = DeferWindowPos(hdwp, child, nullptr, x, y, cx, cy, SWP_NOACTIVATE | SWP_NOZORDER); - } + void move(HWND child, int x, int y, int cx, int cy); void pinTopLeft(HWND child, int x, int y, int cx, int cy) { @@ -44,6 +42,6 @@ public: void pinLeftTopBottom(HWND child, int x, int y, int cx, int by) { - move(child, scale(x), scale(y), cx, height - scale(y + by)); + move(child, scale(x), scale(y), scale(cx), height - scale(y + by)); } };