From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/comctl32/comctl32.h | 1 + dlls/comctl32/commctrl.c | 17 +++++++++++++++++ dlls/comctl32/listview.c | 19 +++---------------- dlls/comctl32/rebar.c | 15 +-------------- dlls/comctl32/toolbar.c | 12 +----------- 5 files changed, 23 insertions(+), 41 deletions(-)
diff --git a/dlls/comctl32/comctl32.h b/dlls/comctl32/comctl32.h index 425a34f866b..5dadb9aae6e 100644 --- a/dlls/comctl32/comctl32.h +++ b/dlls/comctl32/comctl32.h @@ -191,6 +191,7 @@ void COMCTL32_DrawInsertMark(HDC hDC, const RECT *lpRect, COLORREF clrInsertMark void COMCTL32_EnsureBitmapSize(HBITMAP *pBitmap, int cxMinWidth, int cyMinHeight, COLORREF crBackground); void COMCTL32_GetFontMetrics(HFONT hFont, TEXTMETRICW *ptm); BOOL COMCTL32_IsReflectedMessage(UINT uMsg); +LRESULT COMCTL32_SetVersion(INT *current_version, INT new_verison); INT Str_GetPtrWtoA(LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen); INT Str_GetPtrAtoW(LPCSTR lpSrc, LPWSTR lpDest, INT nMaxLen); BOOL Str_SetPtrAtoW(LPWSTR *lppDest, LPCSTR lpSrc); diff --git a/dlls/comctl32/commctrl.c b/dlls/comctl32/commctrl.c index f649e2c0a1b..cad1963586c 100644 --- a/dlls/comctl32/commctrl.c +++ b/dlls/comctl32/commctrl.c @@ -3104,3 +3104,20 @@ LRESULT COMCTL32_forward_notify_to_ansi_window(HWND hwnd_notify, NMHDR *hdr, WCH /* Other notifications, no need to convert */ return SendMessageW(hwnd_notify, WM_NOTIFY, hdr->idFrom, (LPARAM)hdr); } + +/* A helper to handle CCM_SETVERSION messages */ +LRESULT COMCTL32_SetVersion(INT *current_version, INT new_verison) +{ +#if __WINE_COMCTL32_VERSION == 6 + return *current_version; +#else + INT old_version; + + if (new_verison > 5) + return -1; + + old_version = *current_version; + *current_version = new_verison; + return old_version; +#endif +} diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index c954ac221ff..7f51838f000 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -327,7 +327,7 @@ typedef struct tagLISTVIEW_INFO BOOL redraw; /* WM_SETREDRAW switch */
/* misc */ - DWORD iVersion; /* CCM_[G,S]ETVERSION */ + INT iVersion; /* CCM_[G,S]ETVERSION */ } LISTVIEW_INFO;
/* @@ -11441,22 +11441,9 @@ static inline LRESULT LISTVIEW_GetVersion(const LISTVIEW_INFO *infoPtr) * -1 when requested version is greater than DLL version; * previous version otherwise */ -static LRESULT LISTVIEW_SetVersion(LISTVIEW_INFO *infoPtr, DWORD iVersion) +static LRESULT LISTVIEW_SetVersion(LISTVIEW_INFO *infoPtr, INT iVersion) { -#if __WINE_COMCTL32_VERSION == 6 - return infoPtr->iVersion; -#else - INT iOldVersion = infoPtr->iVersion; - - if (iVersion > 5) - return -1; - - infoPtr->iVersion = iVersion; - - TRACE("new version %ld\n", iVersion); - - return iOldVersion; -#endif + return COMCTL32_SetVersion(&infoPtr->iVersion, iVersion); }
/*** diff --git a/dlls/comctl32/rebar.c b/dlls/comctl32/rebar.c index 51f13db3aa9..2ce19eb4f19 100644 --- a/dlls/comctl32/rebar.c +++ b/dlls/comctl32/rebar.c @@ -2862,20 +2862,7 @@ REBAR_SetUnicodeFormat (REBAR_INFO *infoPtr, BOOL unicode) static LRESULT REBAR_SetVersion (REBAR_INFO *infoPtr, INT iVersion) { -#if __WINE_COMCTL32_VERSION == 6 - return infoPtr->iVersion; -#else - INT iOldVersion = infoPtr->iVersion; - - if (iVersion > 5) - return -1; - - infoPtr->iVersion = iVersion; - - TRACE("new version %d\n", iVersion); - - return iOldVersion; -#endif + return COMCTL32_SetVersion(&infoPtr->iVersion, iVersion); }
diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index 2c5ce1a7840..05dcdd7e37b 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -5117,17 +5117,7 @@ TOOLBAR_SetColorScheme (TOOLBAR_INFO *infoPtr, const COLORSCHEME *lParam) static LRESULT TOOLBAR_SetVersion (TOOLBAR_INFO *infoPtr, INT iVersion) { -#if __WINE_COMCTL32_VERSION == 6 - return infoPtr->iVersion; -#else - INT iOldVersion = infoPtr->iVersion; - - if (iVersion > 5) - return -1; - - infoPtr->iVersion = iVersion; - return iOldVersion; -#endif + return COMCTL32_SetVersion(&infoPtr->iVersion, iVersion); }