// ViewPrintPreview.cpp : implementation file
//
#include "stdafx.h"
#include "ViewPrintPreview.h"
#include <afxcontrolbars.h> // MFC support for ribbons and control bars
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CViewPrintPreview
IMPLEMENT_DYNCREATE(CViewPrintPreview, CView)
CViewPrintPreview::CViewPrintPreview()
{
m_pOldFrame=NULL;
}
CViewPrintPreview::~CViewPrintPreview()
{
}
BEGIN_MESSAGE_MAP(CViewPrintPreview, CView)
//{{AFX_MSG_MAP(CViewPrintPreview)
ON_BN_CLICKED(ID_FILE_PRINT, OnBnClickedImp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CViewPrintPreview drawing
void CViewPrintPreview::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CViewPrintPreview diagnostics
#ifdef _DEBUG
void CViewPrintPreview::AssertValid() const
{
CView::AssertValid();
}
void CViewPrintPreview::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CViewPrintPreview message handlers
void CViewPrintPreview::OnFilePrintPreview()
{
AFXPrintPreview(this);
//CView::OnFilePrintPreview();
}
BOOL CViewPrintPreview::OnPreparePrinting(CPrintInfo* pInfo)
{
return DoPreparePrinting(pInfo);
}
void CViewPrintPreview::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
m_pCtrl->OnBeginPrinting(pDC, pInfo);
}
void CViewPrintPreview::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
m_pCtrl->OnPrint(pDC, pInfo);
//CMainFrame* pDato = (CMainFrame*)(AfxGetMainWnd( ));
//pDato->RefreshPages(pInfo->GetMaxPage(), pInfo->m_nCurPage);
}
void CViewPrintPreview::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
{
m_pCtrl->OnEndPrinting(pDC, pInfo);
}
void CViewPrintPreview::OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo, POINT point, CPreviewView* pView)
{
CView::OnEndPrintPreview(pDC, pInfo, point, pView);
// Show the original frame
CMDIChildWndEx* pDato = (CMDIChildWndEx*)pant->GetParent();
//pDato->CambiarCantRows(nrows);
//pant->ShowWindow(SW_SHOW);
::SetWindowLong(this->m_hWnd, GWL_ID, 0);
::SetWindowLong(pant->m_hWnd, GWL_ID, AFX_IDW_PANE_FIRST);
pant->ShowWindow(SW_SHOW);
this->ShowWindow(SW_HIDE);
pDato->RecalcLayout();
if (IsSplitter)
{
CSplitterWnd* sp = (CSplitterWnd*)pant;
sp->RecalcLayout();
}
this->DestroyWindow();
}
void CViewPrintPreview::OnBnClickedImp()
{
m_pCtrl->Print();
}