+
+ DECLARE_DYNAMIC_CLASS(wxDC)
+ DECLARE_NO_COPY_CLASS(wxDC)
+};
+
+// ----------------------------------------------------------------------------
+// wxDCTemp: a wxDC which doesn't free the given HDC (used by wxWidgets
+// only/mainly)
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxDCTemp : public wxDC
+{
+public:
+ // construct a temporary DC with the specified HDC and size (it should be
+ // specified whenever we know it for this HDC)
+ wxDCTemp(WXHDC hdc, const wxSize& size = wxDefaultSize)
+ : wxDC(hdc),
+ m_size(size)
+ {
+ }
+
+ virtual ~wxDCTemp()
+ {
+ // prevent base class dtor from freeing it
+ SetHDC((WXHDC)NULL);
+ }
+
+protected:
+ virtual void DoGetSize(int *w, int *h) const
+ {
+ wxASSERT_MSG( m_size.IsFullySpecified(),
+ _T("size of this DC hadn't been set and is unknown") );
+
+ if ( w )
+ *w = m_size.x;
+ if ( h )
+ *h = m_size.y;
+ }
+
+private:
+ // size of this DC must be explicitly set by SetSize() as we have no way to
+ // find it ourselves
+ const wxSize m_size;
+
+ DECLARE_NO_COPY_CLASS(wxDCTemp)
+};
+
+#endif // _WX_MSW_DC_H_
+