From 365d11bec30b70a437f346f10ed7b0d115d67846 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 16 Apr 2012 14:30:02 +0000 Subject: [PATCH] Fix wxCairoContext creation from wxWindow under MSW. cairo_win32_surface_create() must be passed the window HDC and not HWND itself, the old code calling it was broken. Add WindowHDC object and pass its HDC to this function now to make it work. Closes #14194. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71209 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/graphicc.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index ec4830837f..cf9a017ad1 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -71,6 +71,10 @@ using namespace std; #include #ifdef __WXMSW__ #include +// Notice that the order is important: cairo-win32.h includes windows.h which +// pollutes the global name space with macros so include our own header which +// #undefines them after it. +#include "wx/msw/private.h" #endif #ifdef __WXGTK__ @@ -79,13 +83,6 @@ using namespace std; #include "wx/gtk/dc.h" #endif -#ifdef __WXMSW__ -#include -// We must do this as cairo-win32.h includes windows.h which pollutes the -// global name space with macros. -#include "wx/msw/winundef.h" -#endif - #ifdef __WXMAC__ #include "wx/osx/private.h" #include @@ -400,6 +397,7 @@ public: virtual void Clip( const wxRegion ®ion ); #ifdef __WXMSW__ cairo_surface_t* m_mswSurface; + WindowHDC m_mswWindowHDC; #endif // clips drawings to the rect @@ -1744,7 +1742,10 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, cairo_t *context ) } wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, wxWindow *window) -: wxGraphicsContext(renderer) + : wxGraphicsContext(renderer) +#ifdef __WXMSW__ + , m_mswWindowHDC(GetHwndOf(window)) +#endif { m_enableOffset = true; #ifdef __WXGTK__ @@ -1768,7 +1769,7 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, wxWindow *window) #endif #ifdef __WXMSW__ - m_mswSurface = cairo_win32_surface_create((HDC)window->GetHandle()); + m_mswSurface = cairo_win32_surface_create((HDC)m_mswWindowHDC); Init(cairo_create(m_mswSurface)); #endif -- 2.45.2