From 89b7c500fff052631002843c4408bc552267c184 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 28 May 2018 23:05:41 +0200 Subject: [PATCH] Use the same definitions of wx{Get,Set}WindowXXX() in Win{32,64} By now all compilers/SDKs should hopefully have {Get,Set}WindowLongPtr() and GWLP_XXX constants, so there is no reason to keep separate, and differing by return type in wxGetWindowProc() case (oversight?), versions of these functions for Win32 and Win64 builds. Combine them in a single version appropriate for both cases. --- include/wx/msw/private.h | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index 4cb366ee3e..8e10ccd170 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -1058,54 +1058,28 @@ inline void wxFillRect(HWND hwnd, HDC hdc, HBRUSH hbr) // 32/64 bit helpers // ---------------------------------------------------------------------------- -#ifdef __WIN64__ - -inline void *wxGetWindowProc(HWND hwnd) -{ - return (void *)::GetWindowLongPtr(hwnd, GWLP_WNDPROC); -} - -inline void *wxGetWindowUserData(HWND hwnd) -{ - return (void *)::GetWindowLongPtr(hwnd, GWLP_USERDATA); -} - -inline WNDPROC wxSetWindowProc(HWND hwnd, WNDPROC func) -{ - return (WNDPROC)::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)func); -} - -inline void *wxSetWindowUserData(HWND hwnd, void *data) -{ - return (void *)::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data); -} - -#else // __WIN32__ - // note that the casts to LONG_PTR here are required even on 32-bit machines // for the 64-bit warning mode of later versions of MSVC (C4311/4312) inline WNDPROC wxGetWindowProc(HWND hwnd) { - return (WNDPROC)(LONG_PTR)::GetWindowLong(hwnd, GWL_WNDPROC); + return (WNDPROC)(LONG_PTR)::GetWindowLongPtr(hwnd, GWLP_WNDPROC); } inline void *wxGetWindowUserData(HWND hwnd) { - return (void *)(LONG_PTR)::GetWindowLong(hwnd, GWL_USERDATA); + return (void *)(LONG_PTR)::GetWindowLongPtr(hwnd, GWLP_USERDATA); } inline WNDPROC wxSetWindowProc(HWND hwnd, WNDPROC func) { - return (WNDPROC)(LONG_PTR)::SetWindowLong(hwnd, GWL_WNDPROC, (LONG_PTR)func); + return (WNDPROC)(LONG_PTR)::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)func); } inline void *wxSetWindowUserData(HWND hwnd, void *data) { - return (void *)(LONG_PTR)::SetWindowLong(hwnd, GWL_USERDATA, (LONG_PTR)data); + return (void *)(LONG_PTR)::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data); } -#endif // __WIN64__/__WIN32__ - #endif // wxUSE_GUI && __WXMSW__ #endif // _WX_PRIVATE_H_