#elif defined(__VISUALC__) \
|| defined(__BORLANDC__) \
|| defined(__DMC__) \
+ || defined(__WATCOMC__) \
|| (defined(__GNUWIN32__) || defined(__MINGW32__)) \
|| (defined(__MWERKS__) && defined(__MSL__))
#define wxGetOSFHandle(fd) ((HANDLE)_get_osfhandle(fd))
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
#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())
#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())
#endif // wxUSE_GUI
-#endif
- // _WX_PRIVATE_H_
+#endif // _WX_PRIVATE_H_