added CompatibleBitmap wrapper class

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30628 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2004-11-19 16:47:51 +00:00
parent 06aa40d92c
commit 978bb48f35

View File

@@ -405,6 +405,27 @@ private:
DECLARE_NO_COPY_CLASS(SelectInHDC) 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 // when working with global pointers (which is unfortunately still necessary
// sometimes, e.g. for clipboard) it is important to unlock them exactly as // 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 // many times as we lock them which just asks for using a "smart lock" class