DECLARE_NO_COPY_CLASS(HDCClipper)
};
+// set the given map mode for the life time of this object
+//
+// NB: SetMapMode() is not supported by CE so we also define a helper macro
+// to avoid using it there
+#ifdef __WXWINCE__
+ #define wxCHANGE_HDC_MAP_MODE(hdc, mm)
+#else // !__WXWINCE__
+ class HDCMapModeChanger
+ {
+ public:
+ HDCMapModeChanger(HDC hdc, int mm)
+ : m_hdc(hdc)
+ {
+ m_modeOld = ::SetMapMode(hdc, mm);
+ if ( !m_modeOld )
+ wxLogLastError(_T("SelectClipRgn"));
+ }
+
+ ~HDCMapModeChanger()
+ {
+ if ( m_modeOld )
+ ::SetMapMode(m_hdc, m_modeOld);
+ }
+
+ private:
+ HDC m_hdc;
+ int m_modeOld;
+
+ DECLARE_NO_COPY_CLASS(HDCMapModeChanger)
+ };
+
+ #define wxCHANGE_HDC_MAP_MODE(hdc, mm) \
+ HDCMapModeChanger wxMAKE_UNIQUE_NAME(wxHDCMapModeChanger)(hdc, mm)
+#endif // __WXWINCE__/!__WXWINCE__
+
// smart buffeer using GlobalAlloc/GlobalFree()
class GlobalPtr
{
#else // __WIN32__
-#ifdef __VISUALC__
- // strangely enough, VC++ 7.1 gives warnings about 32 -> 64 bit conversions
- // in the functions below, even in spite of the explicit casts
- #pragma warning(disable:4311)
- #pragma warning(disable:4312)
-#endif
-
-inline void *wxGetWindowProc(HWND hwnd)
+// 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 (void *)::GetWindowLong(hwnd, GWL_WNDPROC);
+ return (WNDPROC)(LONG_PTR)::GetWindowLong(hwnd, GWL_WNDPROC);
}
inline void *wxGetWindowUserData(HWND hwnd)
{
- return (void *)::GetWindowLong(hwnd, GWL_USERDATA);
+ return (void *)(LONG_PTR)::GetWindowLong(hwnd, GWL_USERDATA);
}
inline WNDPROC wxSetWindowProc(HWND hwnd, WNDPROC func)
{
- return (WNDPROC)::SetWindowLong(hwnd, GWL_WNDPROC, (LONG)func);
+ return (WNDPROC)(LONG_PTR)::SetWindowLong(hwnd, GWL_WNDPROC, (LONG_PTR)func);
}
inline void *wxSetWindowUserData(HWND hwnd, void *data)
{
- return (void *)::SetWindowLong(hwnd, GWL_USERDATA, (LONG)data);
+ return (void *)(LONG_PTR)::SetWindowLong(hwnd, GWL_USERDATA, (LONG_PTR)data);
}
-#ifdef __VISUALC__
- #pragma warning(default:4311)
- #pragma warning(default:4312)
-#endif
-
#endif // __WIN64__/__WIN32__
#endif // wxUSE_GUI