Opened 8 years ago

Closed 8 years ago

#12028 closed defect (fixed)

wxGraphicsContext cannot be used with wxPrintPreview

Reported by: jmsalli Owned by:
Priority: normal Milestone:
Component: wxMSW Version: stable-latest
Keywords: Cc:
Blocked By: Blocking:
Patch: no


Under wxMSW, wxGraphicsContext cannot be used to render a print preview because wxPrintPreview's printout->GetDC() returns wxEnhMetaFileDC, which cannot be used to construct a wxGraphicsContext.

Change History (3)

comment:1 Changed 8 years ago by jmsalli

  • Status changed from new to confirmed

comment:2 Changed 8 years ago by jmsalli

Trivial implementation (i.e. simply adding a new wxGraphicsContext::Create(wxEnhMetaFileDC&), with same internals as wxPrinterDC& one) works, but I don't think it is a very good solution. IMHO wxGraphicsContext::Create() should ideally just accept wxDC&, and then fail and return NULL if it cannot be used. Putting the effort of parsing wxDC to wxWindowDC/wxPrinterDC/etc on the application is not very convenient, as can be seen in the printing sample.

Anyhow, I don't know if there could be some subtle problems with that kind of solution.

comment:3 Changed 8 years ago by JMS

  • Resolution set to fixed
  • Status changed from confirmed to closed

(In [64297]) Added wxGraphicsContext::Create(const wxEnhMetaFileDC& dc) so that wxPrintPreview can work with wxMSW's wxGraphicsContext (closes #12028)

Note: See TracTickets for help on using tickets.