From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Fri, 19 Nov 2004 16:47:51 +0000 (+0000)
Subject: added CompatibleBitmap wrapper class
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/978bb48f35a3fa38cebc1e733bec4c9f70ec10f5?ds=inline

added CompatibleBitmap wrapper class


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30628 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h
index 31d97c60f2..98aee97db4 100644
--- a/include/wx/msw/private.h
+++ b/include/wx/msw/private.h
@@ -405,6 +405,27 @@ private:
    DECLARE_NO_COPY_CLASS(SelectInHDC)
 };
 
+// a class for temporary bitmaps
+class CompatibleBitmap
+{
+public:
+    CompatibleBitmap(HDC hdc, int w, int h)
+    {
+        m_hbmp = ::CreateCompatibleBitmap(hdc, w, h);
+    }
+
+    ~CompatibleBitmap()
+    {
+        if ( m_hbmp )
+            ::DeleteObject(m_hbmp);
+    }
+
+    operator HBITMAP() const { return m_hbmp; }
+
+private:
+    HBITMAP m_hbmp;
+};
+
 // when working with global pointers (which is unfortunately still necessary
 // sometimes, e.g. for clipboard) it is important to unlock them exactly as
 // many times as we lock them which just asks for using a "smart lock" class