added HDCClipper() class which automatically unselects clipping region in its dtor
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33468 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
c277569a74
commit
a1372ae2fa
@ -449,6 +449,28 @@ public:
|
||||
operator HRGN() const { return (HRGN)GetObject(); }
|
||||
};
|
||||
|
||||
// class sets the specified clipping region during its life time
|
||||
class HDCClipper
|
||||
{
|
||||
public:
|
||||
HDCClipper(HDC hdc, HRGN hrgn)
|
||||
: m_hdc(hdc)
|
||||
{
|
||||
if ( !::SelectClipRgn(hdc, hrgn) )
|
||||
wxLogLastError(_T("SelectClipRgn"));
|
||||
}
|
||||
|
||||
~HDCClipper()
|
||||
{
|
||||
::SelectClipRgn(m_hdc, NULL);
|
||||
}
|
||||
|
||||
private:
|
||||
HDC m_hdc;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(HDCClipper)
|
||||
};
|
||||
|
||||
// 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
|
||||
|
Loading…
Reference in New Issue
Block a user