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

📄 strollview.cpp

📁 MFC入门例子程序源代码
💻 CPP
字号:
// StrollView.cpp : implementation of the CStrollView class
//

#include "stdafx.h"
#include "Stroll.h"

#include "StrollDoc.h"
#include "StrollView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CStrollView

IMPLEMENT_DYNCREATE(CStrollView, CScrollView)

BEGIN_MESSAGE_MAP(CStrollView, CScrollView)
	//{{AFX_MSG_MAP(CStrollView)
		// 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()

/////////////////////////////////////////////////////////////////////////////
// CStrollView construction/destruction

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

}

CStrollView::~CStrollView()
{
}

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

	return CScrollView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CStrollView drawing

void CStrollView::OnDraw(CDC* pDC)
{
	CStrollDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

//added by yhm
	CRect rect;
	GetClientRect(&rect);
	int x=rect.right/4,y=rect.bottom/2;
	pDC->TextOut(x,y,"这是一个制作智能滚动条的实例");
//added by yhm

	// TODO: add draw code for native data here
}

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

	CSize sizeTotal;
	// TODO: calculate the total size of this view
	sizeTotal.cx = sizeTotal.cy = 300; //yhm 100;
//当窗口小于SizeTotal.cx sizeTotal.cy时显示滚动条
	SetScrollSizes(MM_TEXT, sizeTotal);
//设置滚动条的尺寸
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();
//当对窗口进行声明之后,调用ResizeParentToFit()函数来调整窗口的大小
//added by yhm

}

/////////////////////////////////////////////////////////////////////////////
// CStrollView printing

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

void CStrollView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

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

/////////////////////////////////////////////////////////////////////////////
// CStrollView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CStrollView message handlers

⌨️ 快捷键说明

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