diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj
index 1effaf6..a02cd9a 100644
--- a/DDrawCompat/DDrawCompat.vcxproj
+++ b/DDrawCompat/DDrawCompat.vcxproj
@@ -220,6 +220,7 @@
+
@@ -293,6 +294,7 @@
+
diff --git a/DDrawCompat/DDrawCompat.vcxproj.filters b/DDrawCompat/DDrawCompat.vcxproj.filters
index a7116e4..755c67c 100644
--- a/DDrawCompat/DDrawCompat.vcxproj.filters
+++ b/DDrawCompat/DDrawCompat.vcxproj.filters
@@ -399,6 +399,9 @@
Header Files\Gdi
+
+ Header Files\Gdi
+
@@ -614,5 +617,8 @@
Source Files\Gdi
+
+ Source Files\Gdi
+
\ No newline at end of file
diff --git a/DDrawCompat/Gdi/Gdi.cpp b/DDrawCompat/Gdi/Gdi.cpp
index 2e9187f..b9a308a 100644
--- a/DDrawCompat/Gdi/Gdi.cpp
+++ b/DDrawCompat/Gdi/Gdi.cpp
@@ -5,6 +5,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -39,6 +40,7 @@ namespace Gdi
DisableProcessWindowsGhosting();
DcFunctions::installHooks();
+ Metrics::installHooks();
Palette::installHooks();
PresentationWindow::installHooks();
ScrollFunctions::installHooks();
diff --git a/DDrawCompat/Gdi/Metrics.cpp b/DDrawCompat/Gdi/Metrics.cpp
new file mode 100644
index 0000000..df39786
--- /dev/null
+++ b/DDrawCompat/Gdi/Metrics.cpp
@@ -0,0 +1,43 @@
+#include
+
+#include
+#include
+#include
+
+namespace
+{
+ decltype(&GetSystemMetricsForDpi) g_origGetSystemMetricsForDpi = nullptr;
+
+ int WINAPI getSystemMetrics(int nIndex)
+ {
+ LOG_FUNC("GetSystemMetrics", nIndex);
+ if (SM_CXSIZE == nIndex)
+ {
+ nIndex = SM_CYSIZE;
+ }
+ return LOG_RESULT(CALL_ORIG_FUNC(GetSystemMetrics)(nIndex));
+ }
+
+ int WINAPI getSystemMetricsForDpi(int nIndex, UINT dpi)
+ {
+ LOG_FUNC("GetSystemMetricsForDpi", nIndex, dpi);
+ if (SM_CXSIZE == nIndex)
+ {
+ nIndex = SM_CYSIZE;
+ }
+ return LOG_RESULT(g_origGetSystemMetricsForDpi(nIndex, dpi));
+ }
+}
+
+namespace Gdi
+{
+ namespace Metrics
+ {
+ void installHooks()
+ {
+ HOOK_FUNCTION(user32, GetSystemMetrics, getSystemMetrics);
+ Compat::hookFunction("user32", "GetSystemMetricsForDpi",
+ reinterpret_cast(g_origGetSystemMetricsForDpi), getSystemMetricsForDpi);
+ }
+ }
+}
diff --git a/DDrawCompat/Gdi/Metrics.h b/DDrawCompat/Gdi/Metrics.h
new file mode 100644
index 0000000..973e0bb
--- /dev/null
+++ b/DDrawCompat/Gdi/Metrics.h
@@ -0,0 +1,9 @@
+#pragma once
+
+namespace Gdi
+{
+ namespace Metrics
+ {
+ void installHooks();
+ }
+}
diff --git a/DDrawCompat/Gdi/TitleBar.cpp b/DDrawCompat/Gdi/TitleBar.cpp
index b18429e..298195c 100644
--- a/DDrawCompat/Gdi/TitleBar.cpp
+++ b/DDrawCompat/Gdi/TitleBar.cpp
@@ -1,9 +1,9 @@
-#include "Common/Hook.h"
-#include "Gdi/Gdi.h"
-#include "Gdi/Region.h"
-#include "Gdi/TitleBar.h"
-#include "Gdi/VirtualScreen.h"
-#include "Win32/DisplayMode.h"
+#include
+#include
+#include
+#include
+#include
+#include
namespace
{
@@ -37,7 +37,7 @@ namespace Gdi
}
m_tbi.cbSize = sizeof(m_tbi);
- SendMessage(hwnd, WM_GETTITLEBARINFOEX, 0, reinterpret_cast(&m_tbi));
+ CALL_ORIG_FUNC(DefWindowProcA)(hwnd, WM_GETTITLEBARINFOEX, 0, reinterpret_cast(&m_tbi));
m_hasTitleBar = !IsRectEmpty(&m_tbi.rcTitleBar);
if (!m_hasTitleBar)
{
@@ -62,19 +62,19 @@ namespace Gdi
if (isVisible(i))
{
OffsetRect(&m_tbi.rgrect[i], -m_windowRect.left, -m_windowRect.top);
- adjustButtonSize(m_tbi.rgrect[i]);
+ InflateRect(&m_tbi.rgrect[i], -3, -3);
+ if (TBII_MINIMIZE_BUTTON == i)
+ {
+ m_tbi.rgrect[i].right += 2;
+ }
+ else
+ {
+ m_tbi.rgrect[i].left -= 2;
+ }
}
}
}
- void TitleBar::adjustButtonSize(RECT& rect) const
- {
- rect.left += (rect.right - rect.left - m_buttonWidth) / 2;
- rect.top += (rect.bottom - rect.top - m_buttonHeight) / 2;
- rect.right = rect.left + m_buttonWidth;
- rect.bottom = rect.top + m_buttonHeight;
- }
-
void TitleBar::drawAll() const
{
drawCaption();
diff --git a/DDrawCompat/Gdi/TitleBar.h b/DDrawCompat/Gdi/TitleBar.h
index d43439d..8c0783e 100644
--- a/DDrawCompat/Gdi/TitleBar.h
+++ b/DDrawCompat/Gdi/TitleBar.h
@@ -17,7 +17,6 @@ namespace Gdi
void excludeFromClipRegion() const;
private:
- void adjustButtonSize(RECT& rect) const;
void drawButton(std::size_t tbiIndex, UINT dfcState) const;
bool isVisible(std::size_t tbiIndex) const;