X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/be2572a3253abcd49f8f634658db75443addfcfd..285ba64d0d7e66faae78d357af1cc5386571b654:/include/wx/msw/private.h?ds=inline diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index a7f98d9804..72ef5888c9 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -108,22 +108,6 @@ extern WXDLLIMPEXP_DATA_BASE(HINSTANCE) wxhInstance; #endif #endif -#if wxUSE_PENWIN - WXDLLEXPORT void wxRegisterPenWin(); - WXDLLEXPORT void wxCleanUpPenWin(); - WXDLLEXPORT void wxEnablePenAppHooks (bool hook); -#endif // wxUSE_PENWIN - -#if wxUSE_ITSY_BITSY - #define IBS_HORZCAPTION 0x4000L - #define IBS_VERTCAPTION 0x8000L - - UINT WINAPI ibGetCaptionSize( HWND hWnd ) ; - UINT WINAPI ibSetCaptionSize( HWND hWnd, UINT nSize ) ; - LRESULT WINAPI ibDefWindowProc( HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam ) ; - VOID WINAPI ibAdjustWindowRect( HWND hWnd, LPRECT lprc ) ; -#endif // wxUSE_ITSY_BITSY - /* * Decide what window classes we're going to use * for this combination of CTl3D/FAFA settings @@ -193,6 +177,21 @@ extern LONG APIENTRY _EXPORT #define wxGetOSFHandle(fd) ((HANDLE)_get_osfhandle(fd)) #endif +// close the handle in the class dtor +class AutoHANDLE +{ +public: + wxEXPLICIT AutoHANDLE(HANDLE handle) : m_handle(handle) { } + + bool IsOk() const { return m_handle != INVALID_HANDLE_VALUE; } + operator HANDLE() const { return m_handle; } + + ~AutoHANDLE() { if ( IsOk() ) ::CloseHandle(m_handle); } + +protected: + HANDLE m_handle; +}; + #if wxUSE_GUI #include @@ -520,13 +519,40 @@ private: DECLARE_NO_COPY_CLASS(HDCClipper) }; +// smart buffeer using GlobalAlloc/GlobalFree() +class GlobalPtr +{ +public: + // allocates a block of given size + GlobalPtr(size_t size, unsigned flags = GMEM_MOVEABLE) + { + m_hGlobal = ::GlobalAlloc(flags, size); + if ( !m_hGlobal ) + wxLogLastError(_T("GlobalAlloc")); + } + + ~GlobalPtr() + { + if ( m_hGlobal && ::GlobalFree(m_hGlobal) ) + wxLogLastError(_T("GlobalFree")); + } + + // implicit conversion + operator HGLOBAL() const { return m_hGlobal; } + +private: + HGLOBAL m_hGlobal; + + DECLARE_NO_COPY_CLASS(GlobalPtr) +}; + // 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 -class GlobalPtr +class GlobalPtrLock { public: - GlobalPtr(HGLOBAL hGlobal) : m_hGlobal(hGlobal) + GlobalPtrLock(HGLOBAL hGlobal) : m_hGlobal(hGlobal) { m_ptr = GlobalLock(hGlobal); if ( !m_ptr ) @@ -535,7 +561,7 @@ public: } } - ~GlobalPtr() + ~GlobalPtrLock() { if ( !GlobalUnlock(m_hGlobal) ) { @@ -556,7 +582,7 @@ private: HGLOBAL m_hGlobal; void *m_ptr; - DECLARE_NO_COPY_CLASS(GlobalPtr) + DECLARE_NO_COPY_CLASS(GlobalPtrLock) }; // register the class when it is first needed and unregister it in dtor @@ -776,9 +802,6 @@ inline bool wxStyleHasBorder(long style) wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0; } -// Deferred window moving -bool wxMoveWindowDeferred(HDWP& hdwp, wxWindowBase* win, HWND hWnd, int x, int y, int width, int height); - // ---------------------------------------------------------------------------- // functions mapping HWND to wxWindow // ----------------------------------------------------------------------------