From c092722a147940532b08f62403e182ef279f2c74 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 27 Oct 2021 15:30:02 -0500 Subject: Add CS_HREDRAW and CS_VREDRAW to fix painting issues when resizing. --- .../wixstdba/WixStandardBootstrapperApplication.cpp | 14 ++++---------- src/libs/dutil/WixToolset.DUtil/inc/thmutil.h | 13 +++++++++++++ src/libs/dutil/WixToolset.DUtil/thmutil.cpp | 20 ++++++++++++++++++++ src/samples/thmviewer/display.cpp | 14 +++----------- src/samples/thmviewer/thmviewer.cpp | 9 ++------- .../Manual/BafThmutilTesting/BafThmUtilTesting.cpp | 14 ++++---------- 6 files changed, 46 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp index cdb9d017..23158a1c 100644 --- a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp +++ b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp @@ -2647,31 +2647,25 @@ private: HRESULT CreateMainWindow() { HRESULT hr = S_OK; - HICON hIcon = reinterpret_cast(m_pTheme->hIcon); WNDCLASSW wc = { }; DWORD dwWindowStyle = 0; int x = CW_USEDEFAULT; int y = CW_USEDEFAULT; POINT ptCursor = { }; + ThemeInitializeWindowClass(m_pTheme, &wc, CWixStandardBootstrapperApplication::WndProc, m_hModule, WIXSTDBA_WINDOW_CLASS); + // If the theme did not provide an icon, try using the icon from the bundle engine. - if (!hIcon) + if (!wc.hIcon) { HMODULE hBootstrapperEngine = ::GetModuleHandleW(NULL); if (hBootstrapperEngine) { - hIcon = ::LoadIconW(hBootstrapperEngine, MAKEINTRESOURCEW(1)); + wc.hIcon = ::LoadIconW(hBootstrapperEngine, MAKEINTRESOURCEW(1)); } } // Register the window class and create the window. - wc.lpfnWndProc = CWixStandardBootstrapperApplication::WndProc; - wc.hInstance = m_hModule; - wc.hIcon = hIcon; - wc.hCursor = ::LoadCursorW(NULL, (LPCWSTR)IDC_ARROW); - wc.hbrBackground = m_pTheme->rgFonts[m_pTheme->dwFontId].hBackground; - wc.lpszMenuName = NULL; - wc.lpszClassName = WIXSTDBA_WINDOW_CLASS; if (!::RegisterClassW(&wc)) { ExitWithLastError(hr, "Failed to register window."); diff --git a/src/libs/dutil/WixToolset.DUtil/inc/thmutil.h b/src/libs/dutil/WixToolset.DUtil/inc/thmutil.h index eda81485..cd286854 100644 --- a/src/libs/dutil/WixToolset.DUtil/inc/thmutil.h +++ b/src/libs/dutil/WixToolset.DUtil/inc/thmutil.h @@ -529,6 +529,19 @@ HRESULT DAPI ThemeRegisterVariableCallbacks( __in_opt LPVOID pvContext ); +/******************************************************************** + ThemeInitializeWindowClass - sets defaults for the window class + from the given theme. + +*******************************************************************/ +void DAPI ThemeInitializeWindowClass( + __in THEME* pTheme, + __in WNDCLASSW* pWndClass, + __in WNDPROC pfnWndProc, + __in HINSTANCE hInstance, + __in LPCWSTR wzClassName + ); + /******************************************************************** ThemeCreateParentWindow - creates a parent window for the theme. diff --git a/src/libs/dutil/WixToolset.DUtil/thmutil.cpp b/src/libs/dutil/WixToolset.DUtil/thmutil.cpp index 068638f6..e8c23b6c 100644 --- a/src/libs/dutil/WixToolset.DUtil/thmutil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/thmutil.cpp @@ -824,6 +824,26 @@ LExit: } +DAPI_(void) ThemeInitializeWindowClass( + __in THEME* pTheme, + __in WNDCLASSW* pWndClass, + __in WNDPROC pfnWndProc, + __in HINSTANCE hInstance, + __in LPCWSTR wzClassName + ) +{ + pWndClass->style = CS_HREDRAW | CS_VREDRAW; + pWndClass->hCursor = ::LoadCursorW(NULL, (LPCWSTR)IDC_ARROW); + + pWndClass->lpfnWndProc = pfnWndProc; + pWndClass->hInstance = hInstance; + pWndClass->lpszClassName = wzClassName; + + pWndClass->hIcon = reinterpret_cast(pTheme->hIcon); + pWndClass->hbrBackground = pTheme->rgFonts[pTheme->dwFontId].hBackground; +} + + DAPI_(HRESULT) ThemeCreateParentWindow( __in THEME* pTheme, __in DWORD dwExStyle, diff --git a/src/samples/thmviewer/display.cpp b/src/samples/thmviewer/display.cpp index e64f79c6..9ef88018 100644 --- a/src/samples/thmviewer/display.cpp +++ b/src/samples/thmviewer/display.cpp @@ -78,11 +78,7 @@ static DWORD WINAPI DisplayThreadProc( HANDLE_THEME* pCurrentHandle = NULL; ATOM atomWc = 0; - WNDCLASSW wc = { }; // the following are constant for the display window class. - wc.lpfnWndProc = DisplayWndProc; - wc.hInstance = hInstance; - wc.lpszClassName = THMVWR_WINDOW_CLASS_DISPLAY; - + WNDCLASSW wc = { }; HWND hWnd = NULL; RECT rc = { }; int x = CW_USEDEFAULT; @@ -170,12 +166,8 @@ static DWORD WINAPI DisplayThreadProc( pCurrentHandle = reinterpret_cast(msg.lParam); if (pCurrentHandle) { - wc.hIcon = reinterpret_cast(pCurrentHandle->pTheme->hIcon); - wc.hCursor = ::LoadCursorW(NULL, (LPCWSTR)IDC_ARROW); - if (0 < pCurrentHandle->pTheme->cFonts) - { - wc.hbrBackground = pCurrentHandle->pTheme->rgFonts[pCurrentHandle->pTheme->dwFontId].hBackground; - } + ThemeInitializeWindowClass(pCurrentHandle->pTheme, &wc, DisplayWndProc, hInstance, THMVWR_WINDOW_CLASS_DISPLAY); + atomWc = ::RegisterClassW(&wc); if (!atomWc) { diff --git a/src/samples/thmviewer/thmviewer.cpp b/src/samples/thmviewer/thmviewer.cpp index 1d941323..94b1ef55 100644 --- a/src/samples/thmviewer/thmviewer.cpp +++ b/src/samples/thmviewer/thmviewer.cpp @@ -312,13 +312,8 @@ static HRESULT CreateMainWindowClass( ATOM atom = 0; WNDCLASSW wc = { }; - wc.lpfnWndProc = MainWndProc; - wc.hInstance = hInstance; - wc.hIcon = reinterpret_cast(pTheme->hIcon); - wc.hCursor = ::LoadCursorW(NULL, (LPCWSTR)IDC_ARROW); - wc.hbrBackground = pTheme->rgFonts[pTheme->dwFontId].hBackground; - wc.lpszMenuName = NULL; - wc.lpszClassName = THMVWR_WINDOW_CLASS_MAIN; + ThemeInitializeWindowClass(pTheme, &wc, MainWndProc, hInstance, THMVWR_WINDOW_CLASS_MAIN); + atom = ::RegisterClassW(&wc); if (!atom) { diff --git a/src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp b/src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp index e5ff9131..b502285f 100644 --- a/src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp +++ b/src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp @@ -130,30 +130,24 @@ private: HRESULT CreateTestingWindow() { HRESULT hr = S_OK; - HICON hIcon = reinterpret_cast(m_pBafTheme->hIcon); WNDCLASSW wc = { }; int x = CW_USEDEFAULT; int y = CW_USEDEFAULT; POINT ptCursor = { }; + ThemeInitializeWindowClass(m_pBafTheme, &wc, CBafThmUtilTesting::TestingWndProc, m_hModule, BAFTHMUTILTESTING_WINDOW_CLASS); + // If the theme did not provide an icon, try using the icon from the bundle engine. - if (!hIcon) + if (!wc.hIcon) { HMODULE hBootstrapperEngine = ::GetModuleHandleW(NULL); if (hBootstrapperEngine) { - hIcon = ::LoadIconW(hBootstrapperEngine, MAKEINTRESOURCEW(1)); + wc.hIcon = ::LoadIconW(hBootstrapperEngine, MAKEINTRESOURCEW(1)); } } // Register the window class and create the window. - wc.lpfnWndProc = CBafThmUtilTesting::TestingWndProc; - wc.hInstance = m_hModule; - wc.hIcon = hIcon; - wc.hCursor = ::LoadCursorW(NULL, (LPCWSTR)IDC_ARROW); - wc.hbrBackground = m_pBafTheme->rgFonts[m_pBafTheme->dwFontId].hBackground; - wc.lpszMenuName = NULL; - wc.lpszClassName = BAFTHMUTILTESTING_WINDOW_CLASS; if (!::RegisterClassW(&wc)) { ExitWithLastError(hr, "Failed to register window."); -- cgit v1.2.3-55-g6feb