[wxMSW 2.8.7] wxGraphicsContext sample and problem during create

Ian Britten britten at caris.com
Wed May 28 07:34:45 PDT 2008


Werner Smekal wrote:

> Anyway, not to my surprise this code worked (in opposition to mine) and 
> eventually I found out, that the problem was, that I created the 
> wxGraphicsContext from a pointer(!) to a wxPaintDC not by reference. The 
> same happens with wxGCDC, but ... why is it possible to create a wxGCDC 
> from a pointer to wxPaintDC when the constructors are
> 
> public:
>     wxGCDC(const wxWindowDC& dc);
> #ifdef __WXMSW__
>     wxGCDC( const wxMemoryDC& dc);
> #endif
>     wxGCDC();

Probably because the constructors aren't flagged as 'explicit', and
some implicit conversions are occuring.
[ IMHO, single-parameter constructors should always be marked explicit,
unless implicit conversions are really wanted ]

Ian


More information about the wx-users mailing list