From badf8578b234a1f64ce4a9aa3a61b49a7c7210d0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 16 Apr 2012 14:29:59 +0000 Subject: [PATCH] Add default ctor to wxMSW private WindowHDC helper class. Allow to use objects of this class without any valid HWND, this is useful for the derived classes which may, or may not, need the corresponding HDC. See #14194. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71208 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/private.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index 2875d294c7..622c3b1544 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -417,8 +417,9 @@ private: class WindowHDC { public: + WindowHDC() : m_hwnd(NULL), m_hdc(NULL) { } WindowHDC(HWND hwnd) { m_hdc = ::GetDC(m_hwnd = hwnd); } - ~WindowHDC() { ::ReleaseDC(m_hwnd, m_hdc); } + ~WindowHDC() { if ( m_hwnd && m_hdc ) { ::ReleaseDC(m_hwnd, m_hdc); } } operator HDC() const { return m_hdc; } -- 2.45.2