@joebigelow / wix-1 / commits / 956c6bc4

Use DefDlgProc in thmutil.

#5927

Sean Hall committed Oct 31, 2021 at 14:22 UTC 956c6bc4011618a05d4cff3992df687530a26e67
1 file changed +25 -9
src/libs/dutil/WixToolset.DUtil/thmutil.cpp
+25 -9
@@ -502,7 +502,8 @@ static LRESULT CALLBACK ControlGroupDefWindowProc(
502 __in HWND hWnd,
503 __in UINT uMsg,
504 __in WPARAM wParam,
505 - __in LPARAM lParam
505 + __in LPARAM lParam,
506 + __in BOOL fDialog
507 );
508 static LRESULT CALLBACK PanelWndProc(
509 __in HWND hWnd,
@@ -837,6 +838,7 @@ DAPI_(void) ThemeInitializeWindowClass(
838 )
839 {
840 pWndClass->style = CS_HREDRAW | CS_VREDRAW;
841 + pWndClass->cbWndExtra = DLGWINDOWEXTRA;
842 pWndClass->hCursor = ::LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
843
844 pWndClass->lpfnWndProc = pfnWndProc;
@@ -1120,7 +1122,7 @@ extern "C" LRESULT CALLBACK ThemeDefWindowProc(
1122 }
1123 }
1124
1123 - return ControlGroupDefWindowProc(pTheme, hWnd, uMsg, wParam, lParam);
1125 + return ControlGroupDefWindowProc(pTheme, hWnd, uMsg, wParam, lParam, TRUE);
1126 }
1127
1128
@@ -1703,7 +1705,7 @@ DAPI_(void) ThemeSetFocus(
1705
1706 if (hwndFocus)
1707 {
1706 - ::SetFocus(hwndFocus);
1708 + ::SendMessage(pThemeControl->pTheme->hwndParent, WM_NEXTDLGCTL, (WPARAM)hwndFocus, TRUE);
1709 }
1710 }
1711 }
@@ -5304,7 +5306,7 @@ static BOOL OnNotifyEnMsgFilter(
5306 {
5307 BOOL fShift = 0x8000 & ::GetKeyState(VK_SHIFT);
5308 HWND hwndFocus = ::GetNextDlgTabItem(pTheme->hwndParent, pThemeControl->hWnd, fShift);
5307 - ::SetFocus(hwndFocus);
5309 + ::SendMessage(pTheme->hwndParent, WM_NEXTDLGCTL, (WPARAM)hwndFocus, TRUE);
5310
5311 fProcessed = TRUE;
5312 }
@@ -5493,6 +5495,11 @@ static HRESULT SizeListViewColumns(
5495 int iExtraAvailableSize;
5496 THEME_COLUMN* pColumn = NULL;
5497
5498 + if (!pControl->hWnd)
5499 + {
5500 + ExitFunction();
5501 + }
5502 +
5503 if (!::GetWindowRect(pControl->hWnd, &rcParent))
5504 {
5505 ThmExitWithLastError(hr, "Failed to get window rect of listview control.");
@@ -5548,7 +5555,7 @@ static HRESULT ShowControl(
5555 {
5556 HRESULT hr = S_OK;
5557 DWORD iPageControl = 0;
5551 - HWND hwndFocus = NULL;
5558 + HWND hwndFocus = phwndFocus ? *phwndFocus : NULL;
5559 LPWSTR sczFormatString = NULL;
5560 LPWSTR sczText = NULL;
5561 THEME_SAVEDVARIABLE* pSavedVariable = NULL;
@@ -5851,7 +5858,7 @@ static HRESULT ShowControls(
5858
5859 if (hwndFocus)
5860 {
5854 - ::SetFocus(hwndFocus);
5861 + ::SendMessage(pTheme->hwndParent, WM_NEXTDLGCTL, (WPARAM)hwndFocus, TRUE);
5862 }
5863
5864 LExit:
@@ -5864,7 +5871,8 @@ static LRESULT CALLBACK ControlGroupDefWindowProc(
5871 __in HWND hWnd,
5872 __in UINT uMsg,
5873 __in WPARAM wParam,
5867 - __in LPARAM lParam
5874 + __in LPARAM lParam,
5875 + __in BOOL fDialog
5876 )
5877 {
5878 LRESULT lres = 0;
@@ -5879,6 +5887,9 @@ static LRESULT CALLBACK ControlGroupDefWindowProc(
5887 return TRUE;
5888
5889 case WM_CTLCOLORBTN: __fallthrough;
5890 + case WM_CTLCOLOREDIT: __fallthrough;
5891 + case WM_CTLCOLORLISTBOX: __fallthrough;
5892 + case WM_CTLCOLORSCROLLBAR: __fallthrough;
5893 case WM_CTLCOLORSTATIC:
5894 {
5895 HBRUSH hBrush = NULL;
@@ -5935,10 +5946,15 @@ static LRESULT CALLBACK ControlGroupDefWindowProc(
5946 }
5947 }
5948 break;
5949 +
5950 + case WM_CLOSE: __fallthrough;
5951 + case WM_ERASEBKGND:
5952 + fDialog = FALSE;
5953 + break;
5954 }
5955 }
5956
5941 - return ::DefWindowProcW(hWnd, uMsg, wParam, lParam);
5957 + return fDialog ? ::DefDlgProcW(hWnd, uMsg, wParam, lParam) : ::DefWindowProcW(hWnd, uMsg, wParam, lParam);
5958 }
5959
5960
@@ -5979,7 +5995,7 @@ static LRESULT CALLBACK PanelWndProc(
5995 break;
5996 }
5997
5982 - return ControlGroupDefWindowProc(pControl ? pControl->pTheme : NULL, hWnd, uMsg, wParam, lParam);
5998 + return ControlGroupDefWindowProc(pControl ? pControl->pTheme : NULL, hWnd, uMsg, wParam, lParam, FALSE);
5999 }
6000
6001 static LRESULT CALLBACK StaticOwnerDrawWndProc(