⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 countnumview.cpp

📁 MFC程序开发参考大全 【明日科技】宋坤 刘锐宁 李伟明 【丛 书 名】 软件工程师典藏 【出 版 社】 人民邮电出版社 本书详细介绍了MFC框架中所有常用类及控件的应用
💻 CPP
字号:
// CountNumView.cpp : implementation of the CCountNumView class
//

#include "stdafx.h"
#include "CountNum.h"
#include "MainFrm.h"
#include "CountNumDoc.h"
#include "CountNumView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CCountNumView

IMPLEMENT_DYNCREATE(CCountNumView, CScrollView)

BEGIN_MESSAGE_MAP(CCountNumView, CScrollView)
	//{{AFX_MSG_MAP(CCountNumView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCountNumView construction/destruction

CCountNumView::CCountNumView()
{
	// TODO: add construction code here

}

CCountNumView::~CCountNumView()
{
}

BOOL CCountNumView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CScrollView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CCountNumView drawing

void CCountNumView::OnDraw(CDC* pDC)
{
	CCountNumDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

void CCountNumView::OnInitialUpdate()
{
	CScrollView::OnInitialUpdate();

	CSize sizeTotal;
	// TODO: calculate the total size of this view
	sizeTotal.cx = sizeTotal.cy = 100;
	SetScrollSizes(MM_TEXT, sizeTotal);
}

/////////////////////////////////////////////////////////////////////////////
// CCountNumView printing

BOOL CCountNumView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CCountNumView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
	// TODO: add extra initialization before printing
	CMainFrame *p=(CMainFrame*)AfxGetMainWnd();
	CString n1,n2;
	int num;
	p->m_Edit[0].GetWindowText(n1);
	p->m_Edit[1].GetWindowText(n2);
	num = (atoi(n2)-atoi(n1))/30+1;
	if((atoi(n2)-atoi(n1))%30 == 0)
		num = num - 1;
	pInfo->SetMaxPage(num);

	CString str;
	str.Format("共%d页",num);
	MessageBox(str);
}

void CCountNumView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CCountNumView diagnostics

#ifdef _DEBUG
void CCountNumView::AssertValid() const
{
	CScrollView::AssertValid();
}

void CCountNumView::Dump(CDumpContext& dc) const
{
	CScrollView::Dump(dc);
}

CCountNumDoc* CCountNumView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCountNumDoc)));
	return (CCountNumDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CCountNumView message handlers

void CCountNumView::OnPrint(CDC* pDC, CPrintInfo* pInfo) 
{
	// TODO: Add your specialized code here and/or call the base class
	CMainFrame *p=(CMainFrame*)AfxGetMainWnd();
	CString n1,n2;
	p->m_Edit[0].GetWindowText(n1);
	p->m_Edit[1].GetWindowText(n2);
	int num = 1;
	CString str;
	BOOL re;
	for(int i=atoi(n1),j=0;i<=atoi(n2);i++,j++)
	{
		if((i-atoi(n1))%30==0)
		{
			re = pInfo->m_nCurPage == num;
			num++;
			j = 0;
		}
		if(re)
		{
			str.Format("%d",i);
			pDC->TextOut(500,120+j*60,str);
		}
	}
//	CScrollView::OnPrint(pDC, pInfo);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -