Beispiel #1
0
void
MyPrintout::OnPreparePrinting()
{
    wxLogDebug(_T("OnPreparePrinting"));
    wxLogDebug(_T("DC Size: %d, %d"), GetDC()->GetSize().x, GetDC()->GetSize().y);
    m_drawer.SetDC(GetDC());
    LayoutPages();
}
Beispiel #2
0
//
/// Overriden virtual of TWindow to allow preview frame to create the preview
/// page(s).
//
void
TPreviewWin::SetupWindow()
{
  TDecoratedFrame::SetupWindow();

  // !BB NOTE: The follow order of calls (i.e. calling
  //        SetPrintParams() before calling GetDialogInfo()
  //        is the opposite of the order used by TPrinter::Print
  //        (when we're really printing). However, the following
  //        seems more logical since the 'Printout' can accurately
  //        compute it page info. only after it has received the
  //        PrinterDC...
  //        Investigate and make update so that a 'Printout' can
  //        expect a consistent order of calls whether we're printing
  //        or simply previewing...
  //

  // Hand printout the target DC and page size
  //
  Printout.SetPrintParams(PrnDC, PrinterPageSize);

  // Allow printout to update page range information
  //
  TPrintDialog::TData& data = Printer.GetSetup();
  Printout.GetDialogInfo(data.MinPage, data.MaxPage,
                         data.FromPage, data.ToPage);

  // Create/Initialize Preview Pages
  //
  Page1 = GetNewPreviewPage(Client, Printout, *PrnDC, PrinterPageSize,
                            data.FromPage > 0 ? data.FromPage : 1);
  Page1->Create();
  Page2 = 0;

  LayoutPages();

/*
  data.FromPage = 1;
  data.ToPage = 1;
  data.MinPage = 1;
  data.MaxPage = 1;
*/
}
Beispiel #3
0
// Handles clicking on 'Print' menu item
void CNoteDlg::OnPrint()
{
	if(!LayoutPages())
	{
		MessageBox(_T("Print operation failed"), APP_NAME, MB_ICONERROR | MB_OK);
		return;
	}
	
	CPrintDialog dlg(FALSE);
	dlg.m_pd.hDevMode = m_DevMode.CopyToHDEVMODE();
	dlg.m_pd.hDevNames = m_Printer.CopyToHDEVNAMES();
	dlg.m_pd.nMinPage = 1;
	dlg.m_pd.nMaxPage = (WORD)m_arrPages.GetSize();
	dlg.m_pd.nFromPage = 1;
	dlg.m_pd.nToPage = (WORD)m_arrPages.GetSize();
	dlg.m_pd.Flags &= ~PD_NOPAGENUMS;
	
	if (dlg.DoModal() == IDOK)
	{
		m_DevMode.CopyFromHDEVMODE(dlg.m_pd.hDevMode);
		m_Printer.ClosePrinter();
		m_Printer.OpenPrinter(dlg.m_pd.hDevNames, m_DevMode.m_pDevMode);
		
		CPrintJob job;
		int nMin = 0;
		int nMax = m_arrPages.GetSize() - 1;
		if(dlg.PrintRange() != FALSE)
		{
			nMin = dlg.m_pd.nFromPage - 1;
			nMax = dlg.m_pd.nToPage - 1;
		}
		
		job.StartPrintJob(false, m_Printer, m_DevMode.m_pDevMode, this, 
			APP_NAME, nMin, nMax, (dlg.PrintToFile() != FALSE));
	}
	
	::GlobalFree(dlg.m_pd.hDevMode);
	::GlobalFree(dlg.m_pd.hDevNames);
}