diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index 001d489037..dabb41107a 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -189,9 +189,9 @@ template class AutoHANDLE { public: - wxEXPLICIT AutoHANDLE(HANDLE handle = INVALID_VALUE) : m_handle(handle) { } + wxEXPLICIT AutoHANDLE(HANDLE handle = InvalidHandle()) : m_handle(handle) { } - bool IsOk() const { return m_handle != INVALID_VALUE; } + bool IsOk() const { return m_handle != InvalidHandle(); } operator HANDLE() const { return m_handle; } ~AutoHANDLE() { if ( IsOk() ) DoClose(); } @@ -202,10 +202,17 @@ public: DoClose(); - m_handle = INVALID_VALUE; + m_handle = InvalidHandle(); } protected: + // We need this helper function because integer INVALID_VALUE is not + // implicitly convertible to HANDLE, which is a pointer. + static HANDLE InvalidHandle() + { + return static_cast(INVALID_VALUE); + } + void DoClose() { if ( !::CloseHandle(m_handle) )