aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libs/dutil/WixToolset.DUtil/thmutil.cpp42
1 files changed, 33 insertions, 9 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/thmutil.cpp b/src/libs/dutil/WixToolset.DUtil/thmutil.cpp
index a3dce4c2..53257d8e 100644
--- a/src/libs/dutil/WixToolset.DUtil/thmutil.cpp
+++ b/src/libs/dutil/WixToolset.DUtil/thmutil.cpp
@@ -526,6 +526,12 @@ static void ScaleTheme(
526 __in BOOL fMenu, 526 __in BOOL fMenu,
527 __in DWORD dwExStyle 527 __in DWORD dwExStyle
528 ); 528 );
529static void AdjustThemeWindowRect(
530 __in THEME* pTheme,
531 __in DWORD dwStyle,
532 __in BOOL fMenu,
533 __in DWORD dwExStyle
534 );
529static void ScaleControls( 535static void ScaleControls(
530 __in THEME* pTheme, 536 __in THEME* pTheme,
531 __in DWORD cControls, 537 __in DWORD cControls,
@@ -809,6 +815,7 @@ DAPI_(HRESULT) ThemeCreateParentWindow(
809 RECT* pMonitorRect = NULL; 815 RECT* pMonitorRect = NULL;
810 HMENU hMenu = NULL; 816 HMENU hMenu = NULL;
811 HWND hWnd = NULL; 817 HWND hWnd = NULL;
818 BOOL fScaledTheme = FALSE;
812 819
813 if (pTheme->hwndParent) 820 if (pTheme->hwndParent)
814 { 821 {
@@ -826,6 +833,7 @@ DAPI_(HRESULT) ThemeCreateParentWindow(
826 if (pMonitorContext->nDpi != pTheme->nDpi) 833 if (pMonitorContext->nDpi != pTheme->nDpi)
827 { 834 {
828 ScaleTheme(pTheme, pMonitorContext->nDpi, pMonitorRect->left, pMonitorRect->top, dwStyle, NULL != hMenu, dwExStyle); 835 ScaleTheme(pTheme, pMonitorContext->nDpi, pMonitorRect->left, pMonitorRect->top, dwStyle, NULL != hMenu, dwExStyle);
836 fScaledTheme = TRUE;
829 } 837 }
830 838
831 x = pMonitorRect->left + (pMonitorRect->right - pMonitorRect->left - pTheme->nWindowWidth) / 2; 839 x = pMonitorRect->left + (pMonitorRect->right - pMonitorRect->left - pTheme->nWindowWidth) / 2;
@@ -839,6 +847,12 @@ DAPI_(HRESULT) ThemeCreateParentWindow(
839 } 847 }
840 } 848 }
841 849
850 // Make sure the client area matches the specified width and height.
851 if (!fScaledTheme)
852 {
853 AdjustThemeWindowRect(pTheme, dwStyle, NULL != hMenu, dwExStyle);
854 }
855
842 hWnd = ::CreateWindowExW(dwExStyle, szClassName, szWindowName, dwStyle, x, y, pTheme->nWindowWidth, pTheme->nWindowHeight, hwndParent, hMenu, hInstance, lpParam); 856 hWnd = ::CreateWindowExW(dwExStyle, szClassName, szWindowName, dwStyle, x, y, pTheme->nWindowWidth, pTheme->nWindowHeight, hwndParent, hMenu, hInstance, lpParam);
843 ThmExitOnNullWithLastError(hWnd, hr, "Failed to create theme parent window."); 857 ThmExitOnNullWithLastError(hWnd, hr, "Failed to create theme parent window.");
844 ThmExitOnNull(pTheme->hwndParent, hr, E_INVALIDSTATE, "Theme parent window is not set, make sure ThemeDefWindowProc is called for WM_NCCREATE."); 858 ThmExitOnNull(pTheme->hwndParent, hr, E_INVALIDSTATE, "Theme parent window is not set, make sure ThemeDefWindowProc is called for WM_NCCREATE.");
@@ -6597,8 +6611,6 @@ static void ScaleTheme(
6597 __in DWORD dwExStyle 6611 __in DWORD dwExStyle
6598 ) 6612 )
6599{ 6613{
6600 RECT rect = { };
6601
6602 pTheme->nDpi = nDpi; 6614 pTheme->nDpi = nDpi;
6603 6615
6604 pTheme->nHeight = DpiuScaleValue(pTheme->nDefaultDpiHeight, pTheme->nDpi); 6616 pTheme->nHeight = DpiuScaleValue(pTheme->nDefaultDpiHeight, pTheme->nDpi);
@@ -6606,13 +6618,7 @@ static void ScaleTheme(
6606 pTheme->nMinimumHeight = DpiuScaleValue(pTheme->nDefaultDpiMinimumHeight, pTheme->nDpi); 6618 pTheme->nMinimumHeight = DpiuScaleValue(pTheme->nDefaultDpiMinimumHeight, pTheme->nDpi);
6607 pTheme->nMinimumWidth = DpiuScaleValue(pTheme->nDefaultDpiMinimumWidth, pTheme->nDpi); 6619 pTheme->nMinimumWidth = DpiuScaleValue(pTheme->nDefaultDpiMinimumWidth, pTheme->nDpi);
6608 6620
6609 rect.left = x; 6621 AdjustThemeWindowRect(pTheme, dwStyle, fMenu, dwExStyle);
6610 rect.top = y;
6611 rect.right = x + pTheme->nWidth;
6612 rect.bottom = y + pTheme->nHeight;
6613 DpiuAdjustWindowRect(&rect, dwStyle, fMenu, dwExStyle, pTheme->nDpi);
6614 pTheme->nWindowWidth = rect.right - rect.left;
6615 pTheme->nWindowHeight = rect.bottom - rect.top;
6616 6622
6617 ScaleControls(pTheme, pTheme->cControls, pTheme->rgControls, pTheme->nDpi); 6623 ScaleControls(pTheme, pTheme->cControls, pTheme->rgControls, pTheme->nDpi);
6618 6624
@@ -6622,6 +6628,24 @@ static void ScaleTheme(
6622 } 6628 }
6623} 6629}
6624 6630
6631static void AdjustThemeWindowRect(
6632 __in THEME* pTheme,
6633 __in DWORD dwStyle,
6634 __in BOOL fMenu,
6635 __in DWORD dwExStyle
6636 )
6637{
6638 RECT rect = { };
6639
6640 rect.left = 0;
6641 rect.top = 0;
6642 rect.right = pTheme->nWidth;
6643 rect.bottom = pTheme->nHeight;
6644 DpiuAdjustWindowRect(&rect, dwStyle, fMenu, dwExStyle, pTheme->nDpi);
6645 pTheme->nWindowWidth = rect.right - rect.left;
6646 pTheme->nWindowHeight = rect.bottom - rect.top;
6647}
6648
6625static void ScaleControls( 6649static void ScaleControls(
6626 __in THEME* pTheme, 6650 __in THEME* pTheme,
6627 __in DWORD cControls, 6651 __in DWORD cControls,