diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2021-06-04 13:37:30 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2021-06-04 14:57:11 -0500 |
commit | 1b2b372b452b5aee5dd2b8aa2cbbbe49e8d3c9e6 (patch) | |
tree | e05be8b248320cc3dfd7580ac839bbb3cf80d6c4 /src/libs | |
parent | 700b48c723531bfc38bab185f237d932144f3b26 (diff) | |
download | wix-1b2b372b452b5aee5dd2b8aa2cbbbe49e8d3c9e6.tar.gz wix-1b2b372b452b5aee5dd2b8aa2cbbbe49e8d3c9e6.tar.bz2 wix-1b2b372b452b5aee5dd2b8aa2cbbbe49e8d3c9e6.zip |
Support multiple thmutil in same process.
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/thmutil.cpp | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/thmutil.cpp b/src/libs/dutil/WixToolset.DUtil/thmutil.cpp index 1e0051d4..a3dce4c2 100644 --- a/src/libs/dutil/WixToolset.DUtil/thmutil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/thmutil.cpp | |||
@@ -44,9 +44,6 @@ const COLORREF THEME_INVISIBLE_COLORREF = 0xFFFFFFFF; | |||
44 | const DWORD GROW_FONT_INSTANCES = 3; | 44 | const DWORD GROW_FONT_INSTANCES = 3; |
45 | const DWORD GROW_IMAGE_INSTANCES = 5; | 45 | const DWORD GROW_IMAGE_INSTANCES = 5; |
46 | const DWORD GROW_WINDOW_TEXT = 250; | 46 | const DWORD GROW_WINDOW_TEXT = 250; |
47 | const LPCWSTR THEME_WC_HYPERLINK = L"ThemeHyperLink"; | ||
48 | const LPCWSTR THEME_WC_PANEL = L"ThemePanel"; | ||
49 | const LPCWSTR THEME_WC_STATICOWNERDRAW = L"ThemeStaticOwnerDraw"; | ||
50 | 47 | ||
51 | static Gdiplus::GdiplusStartupInput vgsi; | 48 | static Gdiplus::GdiplusStartupInput vgsi; |
52 | static Gdiplus::GdiplusStartupOutput vgso = { }; | 49 | static Gdiplus::GdiplusStartupOutput vgso = { }; |
@@ -59,6 +56,9 @@ static WNDPROC vpfnStaticOwnerDrawBaseWndProc = NULL; | |||
59 | static HMODULE vhModuleMsftEdit = NULL; | 56 | static HMODULE vhModuleMsftEdit = NULL; |
60 | static HMODULE vhModuleRichEd = NULL; | 57 | static HMODULE vhModuleRichEd = NULL; |
61 | static HCURSOR vhCursorHand = NULL; | 58 | static HCURSOR vhCursorHand = NULL; |
59 | static LPWSTR vsczHyperlinkClass = NULL; | ||
60 | static LPWSTR vsczPanelClass = NULL; | ||
61 | static LPWSTR vsczStaticOwnerDrawClass = NULL; | ||
62 | 62 | ||
63 | enum INTERNAL_CONTROL_STYLE | 63 | enum INTERNAL_CONTROL_STYLE |
64 | { | 64 | { |
@@ -575,6 +575,15 @@ DAPI_(HRESULT) ThemeInitialize( | |||
575 | hr = XmlInitialize(); | 575 | hr = XmlInitialize(); |
576 | ThmExitOnFailure(hr, "Failed to initialize XML."); | 576 | ThmExitOnFailure(hr, "Failed to initialize XML."); |
577 | 577 | ||
578 | hr = StrAllocFormatted(&vsczHyperlinkClass, L"ThemeHyperLink_%p", hModule); | ||
579 | ThmExitOnFailure(hr, "Failed to initialize hyperlink class name."); | ||
580 | |||
581 | hr = StrAllocFormatted(&vsczPanelClass, L"ThemePanel_%p", hModule); | ||
582 | ThmExitOnFailure(hr, "Failed to initialize panel class name."); | ||
583 | |||
584 | hr = StrAllocFormatted(&vsczStaticOwnerDrawClass, L"ThemeStaticOwnerDraw_%p", hModule); | ||
585 | ThmExitOnFailure(hr, "Failed to initialize static owner draw class name."); | ||
586 | |||
578 | hr = RegisterWindowClasses(hModule); | 587 | hr = RegisterWindowClasses(hModule); |
579 | ThmExitOnFailure(hr, "Failed to register theme window classes."); | 588 | ThmExitOnFailure(hr, "Failed to register theme window classes."); |
580 | 589 | ||
@@ -611,23 +620,29 @@ DAPI_(void) ThemeUninitialize() | |||
611 | 620 | ||
612 | if (vhHyperlinkRegisteredModule) | 621 | if (vhHyperlinkRegisteredModule) |
613 | { | 622 | { |
614 | ::UnregisterClassW(THEME_WC_HYPERLINK, vhHyperlinkRegisteredModule); | 623 | ::UnregisterClassW(vsczHyperlinkClass, vhHyperlinkRegisteredModule); |
615 | vhHyperlinkRegisteredModule = NULL; | 624 | vhHyperlinkRegisteredModule = NULL; |
616 | } | 625 | } |
617 | 626 | ||
627 | ReleaseStr(vsczHyperlinkClass); | ||
628 | |||
618 | if (vhPanelRegisteredModule) | 629 | if (vhPanelRegisteredModule) |
619 | { | 630 | { |
620 | ::UnregisterClassW(THEME_WC_PANEL, vhPanelRegisteredModule); | 631 | ::UnregisterClassW(vsczPanelClass, vhPanelRegisteredModule); |
621 | vhPanelRegisteredModule = NULL; | 632 | vhPanelRegisteredModule = NULL; |
622 | } | 633 | } |
623 | 634 | ||
635 | ReleaseStr(vsczPanelClass); | ||
636 | |||
624 | if (vhStaticOwnerDrawRegisteredModule) | 637 | if (vhStaticOwnerDrawRegisteredModule) |
625 | { | 638 | { |
626 | ::UnregisterClassW(THEME_WC_STATICOWNERDRAW, vhStaticOwnerDrawRegisteredModule); | 639 | ::UnregisterClassW(vsczStaticOwnerDrawClass, vhStaticOwnerDrawRegisteredModule); |
627 | vhStaticOwnerDrawRegisteredModule = NULL; | 640 | vhStaticOwnerDrawRegisteredModule = NULL; |
628 | vpfnStaticOwnerDrawBaseWndProc = NULL; | 641 | vpfnStaticOwnerDrawBaseWndProc = NULL; |
629 | } | 642 | } |
630 | 643 | ||
644 | ReleaseStr(vsczStaticOwnerDrawClass); | ||
645 | |||
631 | if (vgdiToken) | 646 | if (vgdiToken) |
632 | { | 647 | { |
633 | GdipUninitialize(vgdiToken); | 648 | GdipUninitialize(vgdiToken); |
@@ -1764,7 +1779,7 @@ static HRESULT RegisterWindowClasses( | |||
1764 | ThmExitWithLastError(hr, "Failed to get button window class."); | 1779 | ThmExitWithLastError(hr, "Failed to get button window class."); |
1765 | } | 1780 | } |
1766 | 1781 | ||
1767 | wcHyperlink.lpszClassName = THEME_WC_HYPERLINK; | 1782 | wcHyperlink.lpszClassName = vsczHyperlinkClass; |
1768 | #pragma prefast(push) | 1783 | #pragma prefast(push) |
1769 | #pragma prefast(disable:25068) | 1784 | #pragma prefast(disable:25068) |
1770 | wcHyperlink.hCursor = vhCursorHand; | 1785 | wcHyperlink.hCursor = vhCursorHand; |
@@ -1772,7 +1787,7 @@ static HRESULT RegisterWindowClasses( | |||
1772 | 1787 | ||
1773 | if (!::RegisterClassW(&wcHyperlink)) | 1788 | if (!::RegisterClassW(&wcHyperlink)) |
1774 | { | 1789 | { |
1775 | ThmExitWithLastError(hr, "Failed to get button window class."); | 1790 | ThmExitWithLastError(hr, "Failed to register hyperlink window class."); |
1776 | } | 1791 | } |
1777 | vhHyperlinkRegisteredModule = hModule; | 1792 | vhHyperlinkRegisteredModule = hModule; |
1778 | 1793 | ||
@@ -1780,10 +1795,10 @@ static HRESULT RegisterWindowClasses( | |||
1780 | wcPanel.lpfnWndProc = PanelWndProc; | 1795 | wcPanel.lpfnWndProc = PanelWndProc; |
1781 | wcPanel.hInstance = hModule; | 1796 | wcPanel.hInstance = hModule; |
1782 | wcPanel.hCursor = ::LoadCursorW(NULL, (LPCWSTR) IDC_ARROW); | 1797 | wcPanel.hCursor = ::LoadCursorW(NULL, (LPCWSTR) IDC_ARROW); |
1783 | wcPanel.lpszClassName = THEME_WC_PANEL; | 1798 | wcPanel.lpszClassName = vsczPanelClass; |
1784 | if (!::RegisterClassW(&wcPanel)) | 1799 | if (!::RegisterClassW(&wcPanel)) |
1785 | { | 1800 | { |
1786 | ThmExitWithLastError(hr, "Failed to register window."); | 1801 | ThmExitWithLastError(hr, "Failed to register panel window class."); |
1787 | } | 1802 | } |
1788 | vhPanelRegisteredModule = hModule; | 1803 | vhPanelRegisteredModule = hModule; |
1789 | 1804 | ||
@@ -1795,7 +1810,7 @@ static HRESULT RegisterWindowClasses( | |||
1795 | pfnStaticOwnerDrawBaseWndProc = wcStaticOwnerDraw.lpfnWndProc; | 1810 | pfnStaticOwnerDrawBaseWndProc = wcStaticOwnerDraw.lpfnWndProc; |
1796 | wcStaticOwnerDraw.lpfnWndProc = StaticOwnerDrawWndProc; | 1811 | wcStaticOwnerDraw.lpfnWndProc = StaticOwnerDrawWndProc; |
1797 | wcStaticOwnerDraw.hInstance = hModule; | 1812 | wcStaticOwnerDraw.hInstance = hModule; |
1798 | wcStaticOwnerDraw.lpszClassName = THEME_WC_STATICOWNERDRAW; | 1813 | wcStaticOwnerDraw.lpszClassName = vsczStaticOwnerDrawClass; |
1799 | if (!::RegisterClassW(&wcStaticOwnerDraw)) | 1814 | if (!::RegisterClassW(&wcStaticOwnerDraw)) |
1800 | { | 1815 | { |
1801 | ThmExitWithLastError(hr, "Failed to register OwnerDraw window class."); | 1816 | ThmExitWithLastError(hr, "Failed to register OwnerDraw window class."); |
@@ -5947,7 +5962,7 @@ static HRESULT LoadControls( | |||
5947 | case THEME_CONTROL_TYPE_BILLBOARD: | 5962 | case THEME_CONTROL_TYPE_BILLBOARD: |
5948 | __fallthrough; | 5963 | __fallthrough; |
5949 | case THEME_CONTROL_TYPE_PANEL: | 5964 | case THEME_CONTROL_TYPE_PANEL: |
5950 | wzWindowClass = THEME_WC_PANEL; | 5965 | wzWindowClass = vsczPanelClass; |
5951 | dwWindowExBits |= WS_EX_CONTROLPARENT; | 5966 | dwWindowExBits |= WS_EX_CONTROLPARENT; |
5952 | #ifdef DEBUG | 5967 | #ifdef DEBUG |
5953 | StrAllocFormatted(&pControl->sczText, L"Panel '%ls', id: %d", pControl->sczName, pControl->wId); | 5968 | StrAllocFormatted(&pControl->sczText, L"Panel '%ls', id: %d", pControl->sczName, pControl->wId); |
@@ -5983,7 +5998,7 @@ static HRESULT LoadControls( | |||
5983 | break; | 5998 | break; |
5984 | 5999 | ||
5985 | case THEME_CONTROL_TYPE_HYPERLINK: // hyperlinks are basically just owner drawn buttons. | 6000 | case THEME_CONTROL_TYPE_HYPERLINK: // hyperlinks are basically just owner drawn buttons. |
5986 | wzWindowClass = THEME_WC_HYPERLINK; | 6001 | wzWindowClass = vsczHyperlinkClass; |
5987 | dwWindowBits |= BS_OWNERDRAW | BTNS_NOPREFIX; | 6002 | dwWindowBits |= BS_OWNERDRAW | BTNS_NOPREFIX; |
5988 | break; | 6003 | break; |
5989 | 6004 | ||
@@ -5995,7 +6010,7 @@ static HRESULT LoadControls( | |||
5995 | case THEME_CONTROL_TYPE_IMAGE: // images are basically just owner drawn static controls (so we can draw .jpgs and .pngs instead of just bitmaps). | 6010 | case THEME_CONTROL_TYPE_IMAGE: // images are basically just owner drawn static controls (so we can draw .jpgs and .pngs instead of just bitmaps). |
5996 | if (THEME_IMAGE_REFERENCE_TYPE_NONE != pControl->Image.imageRef.type) | 6011 | if (THEME_IMAGE_REFERENCE_TYPE_NONE != pControl->Image.imageRef.type) |
5997 | { | 6012 | { |
5998 | wzWindowClass = THEME_WC_STATICOWNERDRAW; | 6013 | wzWindowClass = vsczStaticOwnerDrawClass; |
5999 | dwWindowBits |= SS_OWNERDRAW; | 6014 | dwWindowBits |= SS_OWNERDRAW; |
6000 | pControl->dwInternalStyle |= INTERNAL_CONTROL_STYLE_OWNER_DRAW; | 6015 | pControl->dwInternalStyle |= INTERNAL_CONTROL_STYLE_OWNER_DRAW; |
6001 | } | 6016 | } |
@@ -6022,7 +6037,7 @@ static HRESULT LoadControls( | |||
6022 | case THEME_CONTROL_TYPE_PROGRESSBAR: | 6037 | case THEME_CONTROL_TYPE_PROGRESSBAR: |
6023 | if (pControl->ProgressBar.cImageRef) | 6038 | if (pControl->ProgressBar.cImageRef) |
6024 | { | 6039 | { |
6025 | wzWindowClass = THEME_WC_STATICOWNERDRAW; // no such thing as an owner drawn progress bar so we'll make our own out of a static control. | 6040 | wzWindowClass = vsczStaticOwnerDrawClass; // no such thing as an owner drawn progress bar so we'll make our own out of a static control. |
6026 | dwWindowBits |= SS_OWNERDRAW; | 6041 | dwWindowBits |= SS_OWNERDRAW; |
6027 | pControl->dwInternalStyle |= INTERNAL_CONTROL_STYLE_OWNER_DRAW; | 6042 | pControl->dwInternalStyle |= INTERNAL_CONTROL_STYLE_OWNER_DRAW; |
6028 | } | 6043 | } |