X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/78a94517c0362500316a585445d351eaa52e4b2e..edea62818b7808c11e2c536b52941809f338f2fb:/include/wx/msw/private.h diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index 87beb0aae8..873855f0be 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -186,6 +186,7 @@ extern LONG APIENTRY _EXPORT #elif defined(__VISUALC__) \ || defined(__BORLANDC__) \ || defined(__DMC__) \ + || defined(__WATCOMC__) \ || (defined(__GNUWIN32__) || defined(__MINGW32__)) \ || (defined(__MWERKS__) && defined(__MSL__)) #define wxGetOSFHandle(fd) ((HANDLE)_get_osfhandle(fd)) @@ -414,25 +415,38 @@ private: DECLARE_NO_COPY_CLASS(SelectInHDC) }; +// a class which cleans up any GDI object +class AutoGDIObject +{ +protected: + AutoGDIObject(HGDIOBJ gdiobj) : m_gdiobj(gdiobj) { } + ~AutoGDIObject() { if ( m_gdiobj ) ::DeleteObject(m_gdiobj); } + + HGDIOBJ GetObject() const { return m_gdiobj; } + +private: + HGDIOBJ m_gdiobj; +}; + // a class for temporary bitmaps -class CompatibleBitmap +class CompatibleBitmap : private AutoGDIObject { public: CompatibleBitmap(HDC hdc, int w, int h) + : AutoGDIObject(::CreateCompatibleBitmap(hdc, w, h)) { - m_hbmp = ::CreateCompatibleBitmap(hdc, w, h); } - ~CompatibleBitmap() - { - if ( m_hbmp ) - ::DeleteObject(m_hbmp); - } + operator HBITMAP() const { return (HBITMAP)GetObject(); } +}; - operator HBITMAP() const { return m_hbmp; } +// class automatically destroys the region object +class AutoHRGN : private AutoGDIObject +{ +public: + AutoHRGN(HRGN hrgn) : AutoGDIObject(hrgn) { } -private: - HBITMAP m_hbmp; + operator HRGN() const { return (HRGN)GetObject(); } }; // when working with global pointers (which is unfortunately still necessary @@ -556,8 +570,8 @@ private: #define GetHaccel() ((HACCEL)GetHACCEL()) #define GetHaccelOf(table) ((HACCEL)((table).GetHACCEL())) -#define GetHbrush() ((HPEN)GetResourceHandle()) -#define GetHbrushOf(brush) ((HPEN)(brush).GetResourceHandle()) +#define GetHbrush() ((HBRUSH)GetResourceHandle()) +#define GetHbrushOf(brush) ((HBRUSH)(brush).GetResourceHandle()) #define GetHmenu() ((HMENU)GetHMenu()) #define GetHmenuOf(menu) ((HMENU)menu->GetHMenu()) @@ -568,6 +582,9 @@ private: #define GetHfont() ((HFONT)GetHFONT()) #define GetHfontOf(font) ((HFONT)(font).GetHFONT()) +#define GetHimagelist() ((HIMAGELIST)GetHIMAGELIST()) +#define GetHimagelistOf(imgl) ((HIMAGELIST)imgl->GetHIMAGELIST()) + #define GetHpalette() ((HPALETTE)GetHPALETTE()) #define GetHpaletteOf(pal) ((HPALETTE)(pal).GetHPALETTE()) @@ -736,5 +753,4 @@ inline void *wxSetWindowUserData(HWND hwnd, void *data) #endif // wxUSE_GUI -#endif - // _WX_PRIVATE_H_ +#endif // _WX_PRIVATE_H_