Add CS_HREDRAW and CS_VREDRAW to fix painting issues when resizing.
Sean Hall committed
Oct 27, 2021 at 15:30 UTC
c092722a147940532b08f62403e182ef279f2c74
6 files changed
+46
-38
src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
+4
-10
@@ -2647,31 +2647,25 @@ private:
2647
HRESULT CreateMainWindow()
2648
{
2649
HRESULT hr = S_OK;
2650
- HICON hIcon = reinterpret_cast<HICON>(m_pTheme->hIcon);
2650
WNDCLASSW wc = { };
2651
DWORD dwWindowStyle = 0;
2652
int x = CW_USEDEFAULT;
2653
int y = CW_USEDEFAULT;
2654
POINT ptCursor = { };
2655
2656
+ ThemeInitializeWindowClass(m_pTheme, &wc, CWixStandardBootstrapperApplication::WndProc, m_hModule, WIXSTDBA_WINDOW_CLASS);
2657
+
2658
// If the theme did not provide an icon, try using the icon from the bundle engine.
2658
- if (!hIcon)
2659
+ if (!wc.hIcon)
2660
{
2661
HMODULE hBootstrapperEngine = ::GetModuleHandleW(NULL);
2662
if (hBootstrapperEngine)
2663
{
2663
- hIcon = ::LoadIconW(hBootstrapperEngine, MAKEINTRESOURCEW(1));
2664
+ wc.hIcon = ::LoadIconW(hBootstrapperEngine, MAKEINTRESOURCEW(1));
2665
}
2666
}
2667
2668
// Register the window class and create the window.
2668
- wc.lpfnWndProc = CWixStandardBootstrapperApplication::WndProc;
2669
- wc.hInstance = m_hModule;
2670
- wc.hIcon = hIcon;
2671
- wc.hCursor = ::LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
2672
- wc.hbrBackground = m_pTheme->rgFonts[m_pTheme->dwFontId].hBackground;
2673
- wc.lpszMenuName = NULL;
2674
- wc.lpszClassName = WIXSTDBA_WINDOW_CLASS;
2669
if (!::RegisterClassW(&wc))
2670
{
2671
ExitWithLastError(hr, "Failed to register window.");
src/libs/dutil/WixToolset.DUtil/inc/thmutil.h
+13
@@ -529,6 +529,19 @@ HRESULT DAPI ThemeRegisterVariableCallbacks(
529
__in_opt LPVOID pvContext
530
);
531
532
+/********************************************************************
533
+ ThemeInitializeWindowClass - sets defaults for the window class
534
+ from the given theme.
535
+
536
+*******************************************************************/
537
+void DAPI ThemeInitializeWindowClass(
538
+ __in THEME* pTheme,
539
+ __in WNDCLASSW* pWndClass,
540
+ __in WNDPROC pfnWndProc,
541
+ __in HINSTANCE hInstance,
542
+ __in LPCWSTR wzClassName
543
+ );
544
+
545
/********************************************************************
546
ThemeCreateParentWindow - creates a parent window for the theme.
547
src/libs/dutil/WixToolset.DUtil/thmutil.cpp
+20
@@ -824,6 +824,26 @@ LExit:
824
}
825
826
827
+DAPI_(void) ThemeInitializeWindowClass(
828
+ __in THEME* pTheme,
829
+ __in WNDCLASSW* pWndClass,
830
+ __in WNDPROC pfnWndProc,
831
+ __in HINSTANCE hInstance,
832
+ __in LPCWSTR wzClassName
833
+ )
834
+{
835
+ pWndClass->style = CS_HREDRAW | CS_VREDRAW;
836
+ pWndClass->hCursor = ::LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
837
+
838
+ pWndClass->lpfnWndProc = pfnWndProc;
839
+ pWndClass->hInstance = hInstance;
840
+ pWndClass->lpszClassName = wzClassName;
841
+
842
+ pWndClass->hIcon = reinterpret_cast<HICON>(pTheme->hIcon);
843
+ pWndClass->hbrBackground = pTheme->rgFonts[pTheme->dwFontId].hBackground;
844
+}
845
+
846
+
847
DAPI_(HRESULT) ThemeCreateParentWindow(
848
__in THEME* pTheme,
849
__in DWORD dwExStyle,
src/samples/thmviewer/display.cpp
+3
-11
@@ -78,11 +78,7 @@ static DWORD WINAPI DisplayThreadProc(
78
79
HANDLE_THEME* pCurrentHandle = NULL;
80
ATOM atomWc = 0;
81
- WNDCLASSW wc = { }; // the following are constant for the display window class.
82
- wc.lpfnWndProc = DisplayWndProc;
83
- wc.hInstance = hInstance;
84
- wc.lpszClassName = THMVWR_WINDOW_CLASS_DISPLAY;
85
-
81
+ WNDCLASSW wc = { };
82
HWND hWnd = NULL;
83
RECT rc = { };
84
int x = CW_USEDEFAULT;
@@ -170,12 +166,8 @@ static DWORD WINAPI DisplayThreadProc(
166
pCurrentHandle = reinterpret_cast<HANDLE_THEME*>(msg.lParam);
167
if (pCurrentHandle)
168
{
173
- wc.hIcon = reinterpret_cast<HICON>(pCurrentHandle->pTheme->hIcon);
174
- wc.hCursor = ::LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
175
- if (0 < pCurrentHandle->pTheme->cFonts)
176
- {
177
- wc.hbrBackground = pCurrentHandle->pTheme->rgFonts[pCurrentHandle->pTheme->dwFontId].hBackground;
178
- }
169
+ ThemeInitializeWindowClass(pCurrentHandle->pTheme, &wc, DisplayWndProc, hInstance, THMVWR_WINDOW_CLASS_DISPLAY);
170
+
171
atomWc = ::RegisterClassW(&wc);
172
if (!atomWc)
173
{
src/samples/thmviewer/thmviewer.cpp
+2
-7
@@ -312,13 +312,8 @@ static HRESULT CreateMainWindowClass(
312
ATOM atom = 0;
313
WNDCLASSW wc = { };
314
315
- wc.lpfnWndProc = MainWndProc;
316
- wc.hInstance = hInstance;
317
- wc.hIcon = reinterpret_cast<HICON>(pTheme->hIcon);
318
- wc.hCursor = ::LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
319
- wc.hbrBackground = pTheme->rgFonts[pTheme->dwFontId].hBackground;
320
- wc.lpszMenuName = NULL;
321
- wc.lpszClassName = THMVWR_WINDOW_CLASS_MAIN;
315
+ ThemeInitializeWindowClass(pTheme, &wc, MainWndProc, hInstance, THMVWR_WINDOW_CLASS_MAIN);
316
+
317
atom = ::RegisterClassW(&wc);
318
if (!atom)
319
{
src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp
+4
-10
@@ -130,30 +130,24 @@ private:
130
HRESULT CreateTestingWindow()
131
{
132
HRESULT hr = S_OK;
133
- HICON hIcon = reinterpret_cast<HICON>(m_pBafTheme->hIcon);
133
WNDCLASSW wc = { };
134
int x = CW_USEDEFAULT;
135
int y = CW_USEDEFAULT;
136
POINT ptCursor = { };
137
138
+ ThemeInitializeWindowClass(m_pBafTheme, &wc, CBafThmUtilTesting::TestingWndProc, m_hModule, BAFTHMUTILTESTING_WINDOW_CLASS);
139
+
140
// If the theme did not provide an icon, try using the icon from the bundle engine.
140
- if (!hIcon)
141
+ if (!wc.hIcon)
142
{
143
HMODULE hBootstrapperEngine = ::GetModuleHandleW(NULL);
144
if (hBootstrapperEngine)
145
{
145
- hIcon = ::LoadIconW(hBootstrapperEngine, MAKEINTRESOURCEW(1));
146
+ wc.hIcon = ::LoadIconW(hBootstrapperEngine, MAKEINTRESOURCEW(1));
147
}
148
}
149
150
// Register the window class and create the window.
150
- wc.lpfnWndProc = CBafThmUtilTesting::TestingWndProc;
151
- wc.hInstance = m_hModule;
152
- wc.hIcon = hIcon;
153
- wc.hCursor = ::LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
154
- wc.hbrBackground = m_pBafTheme->rgFonts[m_pBafTheme->dwFontId].hBackground;
155
- wc.lpszMenuName = NULL;
156
- wc.lpszClassName = BAFTHMUTILTESTING_WINDOW_CLASS;
151
if (!::RegisterClassW(&wc))
152
{
153
ExitWithLastError(hr, "Failed to register window.");