From: Zhiyi Zhang <zzhang(a)codeweavers.com> --- dlls/comctl32/comctl32.h | 1 + dlls/comctl32/commctrl.c | 5 +++++ dlls/comctl32_v6/button.c | 6 ++---- dlls/comctl32_v6/combo.c | 7 ++----- dlls/comctl32_v6/edit.c | 4 +--- dlls/comctl32_v6/listbox.c | 7 ++----- 6 files changed, 13 insertions(+), 17 deletions(-) diff --git a/dlls/comctl32/comctl32.h b/dlls/comctl32/comctl32.h index 826f854640e..48ec4c1c149 100644 --- a/dlls/comctl32/comctl32.h +++ b/dlls/comctl32/comctl32.h @@ -187,6 +187,7 @@ typedef struct extern COMCTL32_SysColor comctl32_color; /* Internal function */ +void COMCTL32_CloseThemeForWindow(HWND hwnd); HWND COMCTL32_CreateToolTip(HWND); void COMCTL32_DrawStatusText(HDC hdc, LPCRECT lprc, LPCWSTR text, UINT style, BOOL draw_background); void COMCTL32_OpenThemeForWindow(HWND hwnd, const WCHAR *theme_class); diff --git a/dlls/comctl32/commctrl.c b/dlls/comctl32/commctrl.c index 3a364ac8aba..d74ff7d1fd8 100644 --- a/dlls/comctl32/commctrl.c +++ b/dlls/comctl32/commctrl.c @@ -3110,6 +3110,11 @@ void COMCTL32_OpenThemeForWindow(HWND hwnd, const WCHAR *theme_class) OpenThemeData(hwnd, theme_class); } +void COMCTL32_CloseThemeForWindow(HWND hwnd) +{ + CloseThemeData(GetWindowTheme(hwnd)); +} + /* A helper to handle CCM_SETVERSION messages */ LRESULT COMCTL32_SetVersion(INT *current_version, INT new_version) { diff --git a/dlls/comctl32_v6/button.c b/dlls/comctl32_v6/button.c index b806fc1d0c2..5667cb31bd6 100644 --- a/dlls/comctl32_v6/button.c +++ b/dlls/comctl32_v6/button.c @@ -545,13 +545,11 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L } case WM_DESTROY: - theme = GetWindowTheme( hWnd ); - CloseThemeData( theme ); + COMCTL32_CloseThemeForWindow( hWnd ); break; case WM_THEMECHANGED: - theme = GetWindowTheme( hWnd ); - CloseThemeData( theme ); + COMCTL32_CloseThemeForWindow( hWnd ); COMCTL32_OpenThemeForWindow( hWnd, WC_BUTTONW ); InvalidateRect( hWnd, NULL, TRUE ); break; diff --git a/dlls/comctl32_v6/combo.c b/dlls/comctl32_v6/combo.c index b8e0668525f..7eb6383f831 100644 --- a/dlls/comctl32_v6/combo.c +++ b/dlls/comctl32_v6/combo.c @@ -1659,7 +1659,6 @@ static LRESULT COMBO_GetComboBoxInfo(const HEADCOMBO *lphc, COMBOBOXINFO *pcbi) static LRESULT CALLBACK COMBO_WindowProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) { HEADCOMBO *lphc = (HEADCOMBO *)GetWindowLongPtrW( hwnd, 0 ); - HTHEME theme; TRACE("[%p]: msg %#x, wp %Ix, lp %Ix\n", hwnd, message, wParam, lParam ); @@ -1689,13 +1688,11 @@ static LRESULT CALLBACK COMBO_WindowProc( HWND hwnd, UINT message, WPARAM wParam } case WM_DESTROY: - theme = GetWindowTheme( hwnd ); - CloseThemeData( theme ); + COMCTL32_CloseThemeForWindow( hwnd ); break; case WM_THEMECHANGED: - theme = GetWindowTheme( hwnd ); - CloseThemeData( theme ); + COMCTL32_CloseThemeForWindow( hwnd ); COMCTL32_OpenThemeForWindow( hwnd, WC_COMBOBOXW ); InvalidateRect( hwnd, NULL, TRUE ); break; diff --git a/dlls/comctl32_v6/edit.c b/dlls/comctl32_v6/edit.c index f34fecaa1cf..8cfa6f7c7ef 100644 --- a/dlls/comctl32_v6/edit.c +++ b/dlls/comctl32_v6/edit.c @@ -4461,10 +4461,8 @@ static LRESULT EDIT_WM_Create(EDITSTATE *es, const WCHAR *name) static LRESULT EDIT_WM_NCDestroy(EDITSTATE *es) { LINEDEF *pc, *pp; - HTHEME theme; - theme = GetWindowTheme(es->hwndSelf); - CloseThemeData(theme); + COMCTL32_CloseThemeForWindow(es->hwndSelf); /* The app can own the text buffer handle */ if (es->hloc32W && (es->hloc32W != es->hlocapp)) diff --git a/dlls/comctl32_v6/listbox.c b/dlls/comctl32_v6/listbox.c index 51da1c1daec..543b506d3c2 100644 --- a/dlls/comctl32_v6/listbox.c +++ b/dlls/comctl32_v6/listbox.c @@ -2665,8 +2665,7 @@ static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc ) */ static BOOL LISTBOX_Destroy( LB_DESCR *descr ) { - HTHEME theme = GetWindowTheme( descr->self ); - CloseThemeData( theme ); + COMCTL32_CloseThemeForWindow( descr->self ); LISTBOX_ResetContent( descr ); SetWindowLongPtrW( descr->self, 0, 0 ); HeapFree( GetProcessHeap(), 0, descr ); @@ -2681,7 +2680,6 @@ static LRESULT CALLBACK LISTBOX_WindowProc( HWND hwnd, UINT msg, WPARAM wParam, { LB_DESCR *descr = (LB_DESCR *)GetWindowLongPtrW( hwnd, 0 ); HEADCOMBO *lphc = NULL; - HTHEME theme; LRESULT ret; if (!descr) @@ -3158,8 +3156,7 @@ static LRESULT CALLBACK LISTBOX_WindowProc( HWND hwnd, UINT msg, WPARAM wParam, break; case WM_THEMECHANGED: - theme = GetWindowTheme( hwnd ); - CloseThemeData( theme ); + COMCTL32_CloseThemeForWindow( hwnd ); COMCTL32_OpenThemeForWindow( hwnd, WC_LISTBOXW ); InvalidateRect( hwnd, NULL, TRUE ); break; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9221