From e0e6ac8acc4c32513e9b8a37eb551471e032415f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 26 Sep 2006 23:51:29 +0000 Subject: [PATCH] allow specifying the size of wxDCTemp and do specify it for the one used with wxEraseEvents git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41475 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/dc.h | 17 +++++++++++++---- src/msw/window.cpp | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/wx/msw/dc.h b/include/wx/msw/dc.h index 1bfa0488d6..a6021d164f 100644 --- a/include/wx/msw/dc.h +++ b/include/wx/msw/dc.h @@ -297,7 +297,11 @@ protected: class WXDLLEXPORT wxDCTemp : public wxDC { public: - wxDCTemp(WXHDC hdc) : wxDC(hdc) + // construct a temporary DC with the specified HDC and size (it should be + // specified whenever we know it for this HDC) + wxDCTemp(WXHDC hdc, const wxSize& size = wxDefaultSize) + : wxDC(hdc), + m_size(size) { } @@ -310,15 +314,20 @@ public: protected: virtual void DoGetSize(int *w, int *h) const { - wxFAIL_MSG( _T("no way to retrieve the size of generic DC") ); + wxASSERT_MSG( m_size.IsFullySpecified(), + _T("size of this DC hadn't been set and is unknown") ); if ( w ) - *w = 0; + *w = m_size.x; if ( h ) - *h = 0; + *h = m_size.y; } private: + // size of this DC must be explicitly set by SetSize() as we have no way to + // find it ourselves + const wxSize m_size; + DECLARE_NO_COPY_CLASS(wxDCTemp) }; diff --git a/src/msw/window.cpp b/src/msw/window.cpp index eb18a5e6b1..f5e330a252 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -4365,7 +4365,7 @@ void wxWindowMSW::OnPaint(wxPaintEvent& event) bool wxWindowMSW::HandleEraseBkgnd(WXHDC hdc) { - wxDCTemp dc(hdc); + wxDCTemp dc(hdc, GetClientSize()); dc.SetHDC(hdc); dc.SetWindow((wxWindow *)this); -- 2.45.2