// PrintView.cpp : implementation file
//
#include "stdafx.h"
#include "PrintView.h"
#include "PrintFrame.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPrintView
IMPLEMENT_DYNCREATE(CPrintView, CView)
CPrintView::CPrintView()
{
m_bPrint = TRUE;
}
CPrintView::~CPrintView()
{
}
BEGIN_MESSAGE_MAP(CPrintView, CView)
//{{AFX_MSG_MAP(CPrintView)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPrintView drawing
void CPrintView::OnDraw(CDC* pDC)
{
//CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CPrintView diagnostics
#ifdef _DEBUG
void CPrintView::AssertValid() const
{
CView::AssertValid();
}
void CPrintView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CPrintView message handlers
void CPrintView::OnMyPrint()
{
GetParent()->ShowWindow(SW_SHOWMAXIMIZED);
m_bPrint = TRUE;
CView::OnFilePrint();
}
void CPrintView::OnMyPrintPreview()
{
GetParent()->ShowWindow(SW_SHOWMAXIMIZED);
m_bPrint=FALSE;
CView::OnFilePrintPreview();
}
BOOL CPrintView::OnPreparePrinting(CPrintInfo* pInfo)
{
if(DoPreparePrinting(pInfo))
return TRUE;
else
{
GetParent()->DestroyWindow();
return FALSE;
}
}
void CPrintView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
CView::OnBeginPrinting(pDC, pInfo);
CPrintFrame *pFrame =(CPrintFrame *)GetParent();
pFrame->m_pCallerDlg->SendMessage(WM_BEGIN_PRINTING,(WPARAM) pDC, (LPARAM) pInfo);
}
void CPrintView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
{
CView::OnEndPrinting(pDC, pInfo);
CPrintFrame *pFrame =(CPrintFrame *)GetParent();
pFrame->m_pCallerDlg->SendMessage(WM_END_PRINTING,(WPARAM) pDC, (LPARAM) pInfo);
if(m_bPrint) //直接打印,不是预览
GetParent()->DestroyWindow();
}
void CPrintView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
CPrintFrame *pFrame =(CPrintFrame *)GetParent();
pFrame->m_pCallerDlg->SendMessage(WM_MY_PRINT,(WPARAM) pDC, (LPARAM) pInfo) ;
}
void CPrintView::OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo, POINT point, CPreviewView* pView)
{
// TODO: Add your specialized code here and/or call the base class
CView::OnEndPrintPreview(pDC, pInfo, point, pView);
GetParent()->DestroyWindow();
}
void CPrintFrame::FullScreenModeOn()
{
GetWindowPlacement( &m_OldWndPlacement);
CRect WindowRect;
GetWindowRect(&WindowRect);
CRect ClientRect;
RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST, reposQuery, &ClientRect);
ClientToScreen(&ClientRect);
// 获取屏幕的分辨率
int nFullWidth=GetSystemMetrics(SM_CXSCREEN);
int nFullHeight=GetSystemMetrics(SM_CYSCREEN);
//将除控制条外的客户区全屏显示到从(0,0)到(nFullWidth, nFullHeight)区域,
//将(0,0)和(nFullWidth, nFullHeight)两个点外扩充原窗口和除控制条之外的 客户区位置间的差值, 就得到全屏显示的窗口位置
m_FullScreenRect.left = WindowRect.left - ClientRect.left;
m_FullScreenRect.top = WindowRect.top - ClientRect.top;
m_FullScreenRect.right = WindowRect.right - ClientRect.right + nFullWidth;
m_FullScreenRect.bottom = WindowRect.bottom - ClientRect.bottom + nFullHeight;
m_bFullScreenMode = TRUE;
//设置全屏显示标志为 TRUE
//进入全屏显示状态
WINDOWPLACEMENT wndpl;
wndpl.length=sizeof(WINDOWPLACEMENT);
wndpl.flags=0;
wndpl.showCmd=SW_SHOWNORMAL;
wndpl.rcNormalPosition=m_FullScreenRect;
SetWindowPlacement(&wndpl);
m_bFullScreenMode=true;
}
评论0
最新资源