diff options
| author | Andrij Abyzov <aabyzov@slb.com> | 2021-02-08 20:00:00 +0100 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2021-02-09 10:42:00 -0600 |
| commit | 931d4e4d641155ab0c90fe7717abb12db4736317 (patch) | |
| tree | 6b35787737c324d55a9379d80cb78078256c6c9a /src | |
| parent | bee6a20d1c7d807b5023d932ae179db1bc9a0f80 (diff) | |
| download | wix-931d4e4d641155ab0c90fe7717abb12db4736317.tar.gz wix-931d4e4d641155ab0c90fe7717abb12db4736317.tar.bz2 wix-931d4e4d641155ab0c90fe7717abb12db4736317.zip | |
WIXBUG4931 Fix drawing of image static controls
Diffstat (limited to 'src')
| -rw-r--r-- | src/dutil/thmutil.cpp | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/src/dutil/thmutil.cpp b/src/dutil/thmutil.cpp index 6c9c5cd6..9b9bf15e 100644 --- a/src/dutil/thmutil.cpp +++ b/src/dutil/thmutil.cpp | |||
| @@ -40,6 +40,7 @@ const DWORD GROW_FONT_INSTANCES = 3; | |||
| 40 | const DWORD GROW_WINDOW_TEXT = 250; | 40 | const DWORD GROW_WINDOW_TEXT = 250; |
| 41 | const LPCWSTR THEME_WC_HYPERLINK = L"ThemeHyperLink"; | 41 | const LPCWSTR THEME_WC_HYPERLINK = L"ThemeHyperLink"; |
| 42 | const LPCWSTR THEME_WC_PANEL = L"ThemePanel"; | 42 | const LPCWSTR THEME_WC_PANEL = L"ThemePanel"; |
| 43 | const LPCWSTR THEME_WC_STATICOWNERDRAW = L"ThemeStaticOwnerDraw"; | ||
| 43 | 44 | ||
| 44 | static Gdiplus::GdiplusStartupInput vgsi; | 45 | static Gdiplus::GdiplusStartupInput vgsi; |
| 45 | static Gdiplus::GdiplusStartupOutput vgso = { }; | 46 | static Gdiplus::GdiplusStartupOutput vgso = { }; |
| @@ -47,6 +48,8 @@ static ULONG_PTR vgdiToken = 0; | |||
| 47 | static ULONG_PTR vgdiHookToken = 0; | 48 | static ULONG_PTR vgdiHookToken = 0; |
| 48 | static HMODULE vhHyperlinkRegisteredModule = NULL; | 49 | static HMODULE vhHyperlinkRegisteredModule = NULL; |
| 49 | static HMODULE vhPanelRegisteredModule = NULL; | 50 | static HMODULE vhPanelRegisteredModule = NULL; |
| 51 | static HMODULE vhStaticOwnerDrawRegisteredModule = NULL; | ||
| 52 | static WNDPROC vpfnStaticOwnerDrawBaseWndProc = NULL; | ||
| 50 | static HMODULE vhModuleMsftEdit = NULL; | 53 | static HMODULE vhModuleMsftEdit = NULL; |
| 51 | static HMODULE vhModuleRichEd = NULL; | 54 | static HMODULE vhModuleRichEd = NULL; |
| 52 | static HCURSOR vhCursorHand = NULL; | 55 | static HCURSOR vhCursorHand = NULL; |
| @@ -348,6 +351,12 @@ static LRESULT CALLBACK PanelWndProc( | |||
| 348 | __in WPARAM wParam, | 351 | __in WPARAM wParam, |
| 349 | __in LPARAM lParam | 352 | __in LPARAM lParam |
| 350 | ); | 353 | ); |
| 354 | static LRESULT CALLBACK StaticOwnerDrawWndProc( | ||
| 355 | __in HWND hWnd, | ||
| 356 | __in UINT uMsg, | ||
| 357 | __in WPARAM wParam, | ||
| 358 | __in LPARAM lParam | ||
| 359 | ); | ||
| 351 | static HRESULT LocalizeControls( | 360 | static HRESULT LocalizeControls( |
| 352 | __in DWORD cControls, | 361 | __in DWORD cControls, |
| 353 | __in THEME_CONTROL* rgControls, | 362 | __in THEME_CONTROL* rgControls, |
| @@ -479,6 +488,13 @@ DAPI_(void) ThemeUninitialize() | |||
| 479 | vhPanelRegisteredModule = NULL; | 488 | vhPanelRegisteredModule = NULL; |
| 480 | } | 489 | } |
| 481 | 490 | ||
| 491 | if (vhStaticOwnerDrawRegisteredModule) | ||
| 492 | { | ||
| 493 | ::UnregisterClassW(THEME_WC_STATICOWNERDRAW, vhStaticOwnerDrawRegisteredModule); | ||
| 494 | vhStaticOwnerDrawRegisteredModule = NULL; | ||
| 495 | vpfnStaticOwnerDrawBaseWndProc = NULL; | ||
| 496 | } | ||
| 497 | |||
| 482 | if (vgdiToken) | 498 | if (vgdiToken) |
| 483 | { | 499 | { |
| 484 | GdipUninitialize(vgdiToken); | 500 | GdipUninitialize(vgdiToken); |
| @@ -1598,6 +1614,8 @@ static HRESULT RegisterWindowClasses( | |||
| 1598 | HRESULT hr = S_OK; | 1614 | HRESULT hr = S_OK; |
| 1599 | WNDCLASSW wcHyperlink = { }; | 1615 | WNDCLASSW wcHyperlink = { }; |
| 1600 | WNDCLASSW wcPanel = { }; | 1616 | WNDCLASSW wcPanel = { }; |
| 1617 | WNDCLASSW wcStaticOwnerDraw = { }; | ||
| 1618 | WNDPROC pfnStaticOwnerDrawBaseWndProc = NULL; | ||
| 1601 | 1619 | ||
| 1602 | vhCursorHand = ::LoadCursorA(NULL, IDC_HAND); | 1620 | vhCursorHand = ::LoadCursorA(NULL, IDC_HAND); |
| 1603 | 1621 | ||
| @@ -1630,6 +1648,22 @@ static HRESULT RegisterWindowClasses( | |||
| 1630 | } | 1648 | } |
| 1631 | vhPanelRegisteredModule = hModule; | 1649 | vhPanelRegisteredModule = hModule; |
| 1632 | 1650 | ||
| 1651 | if (!::GetClassInfoW(NULL, WC_STATICW, &wcStaticOwnerDraw)) | ||
| 1652 | { | ||
| 1653 | ThmExitWithLastError(hr, "Failed to get static window class."); | ||
| 1654 | } | ||
| 1655 | |||
| 1656 | pfnStaticOwnerDrawBaseWndProc = wcStaticOwnerDraw.lpfnWndProc; | ||
| 1657 | wcStaticOwnerDraw.lpfnWndProc = StaticOwnerDrawWndProc; | ||
| 1658 | wcStaticOwnerDraw.hInstance = hModule; | ||
| 1659 | wcStaticOwnerDraw.lpszClassName = THEME_WC_STATICOWNERDRAW; | ||
| 1660 | if (!::RegisterClassW(&wcStaticOwnerDraw)) | ||
| 1661 | { | ||
| 1662 | ThmExitWithLastError(hr, "Failed to register OwnerDraw window class."); | ||
| 1663 | } | ||
| 1664 | vhStaticOwnerDrawRegisteredModule = hModule; | ||
| 1665 | vpfnStaticOwnerDrawBaseWndProc = pfnStaticOwnerDrawBaseWndProc; | ||
| 1666 | |||
| 1633 | 1667 | ||
| 1634 | LExit: | 1668 | LExit: |
| 1635 | return hr; | 1669 | return hr; |
| @@ -4919,6 +4953,21 @@ static LRESULT CALLBACK PanelWndProc( | |||
| 4919 | return ControlGroupDefWindowProc(pTheme, hWnd, uMsg, wParam, lParam); | 4953 | return ControlGroupDefWindowProc(pTheme, hWnd, uMsg, wParam, lParam); |
| 4920 | } | 4954 | } |
| 4921 | 4955 | ||
| 4956 | static LRESULT CALLBACK StaticOwnerDrawWndProc( | ||
| 4957 | __in HWND hWnd, | ||
| 4958 | __in UINT uMsg, | ||
| 4959 | __in WPARAM wParam, | ||
| 4960 | __in LPARAM lParam | ||
| 4961 | ) | ||
| 4962 | { | ||
| 4963 | switch (uMsg) | ||
| 4964 | { | ||
| 4965 | case WM_UPDATEUISTATE: | ||
| 4966 | return ::DefWindowProc(hWnd, uMsg, wParam, lParam); | ||
| 4967 | default: | ||
| 4968 | return (*vpfnStaticOwnerDrawBaseWndProc)(hWnd, uMsg, wParam, lParam); | ||
| 4969 | } | ||
| 4970 | } | ||
| 4922 | 4971 | ||
| 4923 | static HRESULT LoadControls( | 4972 | static HRESULT LoadControls( |
| 4924 | __in THEME* pTheme, | 4973 | __in THEME* pTheme, |
| @@ -5011,7 +5060,7 @@ static HRESULT LoadControls( | |||
| 5011 | case THEME_CONTROL_TYPE_IMAGE: // images are basically just owner drawn static controls (so we can draw .jpgs and .pngs instead of just bitmaps). | 5060 | case THEME_CONTROL_TYPE_IMAGE: // images are basically just owner drawn static controls (so we can draw .jpgs and .pngs instead of just bitmaps). |
| 5012 | if (pControl->hImage || (pTheme->hImage && 0 <= pControl->nSourceX && 0 <= pControl->nSourceY)) | 5061 | if (pControl->hImage || (pTheme->hImage && 0 <= pControl->nSourceX && 0 <= pControl->nSourceY)) |
| 5013 | { | 5062 | { |
| 5014 | wzWindowClass = WC_STATICW; | 5063 | wzWindowClass = THEME_WC_STATICOWNERDRAW; |
| 5015 | dwWindowBits |= SS_OWNERDRAW; | 5064 | dwWindowBits |= SS_OWNERDRAW; |
| 5016 | pControl->dwInternalStyle |= INTERNAL_CONTROL_STYLE_OWNER_DRAW; | 5065 | pControl->dwInternalStyle |= INTERNAL_CONTROL_STYLE_OWNER_DRAW; |
| 5017 | } | 5066 | } |
| @@ -5038,7 +5087,7 @@ static HRESULT LoadControls( | |||
| 5038 | case THEME_CONTROL_TYPE_PROGRESSBAR: | 5087 | case THEME_CONTROL_TYPE_PROGRESSBAR: |
| 5039 | if (pControl->hImage || (pTheme->hImage && 0 <= pControl->nSourceX && 0 <= pControl->nSourceY)) | 5088 | if (pControl->hImage || (pTheme->hImage && 0 <= pControl->nSourceX && 0 <= pControl->nSourceY)) |
| 5040 | { | 5089 | { |
| 5041 | wzWindowClass = WC_STATICW; // no such thing as an owner drawn progress bar so we'll make our own out of a static control. | 5090 | wzWindowClass = THEME_WC_STATICOWNERDRAW; // no such thing as an owner drawn progress bar so we'll make our own out of a static control. |
| 5042 | dwWindowBits |= SS_OWNERDRAW; | 5091 | dwWindowBits |= SS_OWNERDRAW; |
| 5043 | pControl->dwInternalStyle |= INTERNAL_CONTROL_STYLE_OWNER_DRAW; | 5092 | pControl->dwInternalStyle |= INTERNAL_CONTROL_STYLE_OWNER_DRAW; |
| 5044 | } | 5093 | } |
