ex030204view.cpp

来自「深入浅出Visual C++入门进阶与应用实例 随书光盘 作者 何志丹」· C++ 代码 · 共 116 行

CPP
116
字号
// Ex030204View.cpp : implementation of the CEx030204View class
//

#include "stdafx.h"
#include "Ex030204.h"

#include "Ex030204Doc.h"
#include "Ex030204View.h"

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

#include "MenuEx.h"
/////////////////////////////////////////////////////////////////////////////
// CEx030204View

IMPLEMENT_DYNCREATE(CEx030204View, CView)

BEGIN_MESSAGE_MAP(CEx030204View, CView)
	//{{AFX_MSG_MAP(CEx030204View)
	ON_WM_RBUTTONDOWN()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEx030204View construction/destruction

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

}

CEx030204View::~CEx030204View()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CEx030204View drawing

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

/////////////////////////////////////////////////////////////////////////////
// CEx030204View printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CEx030204View diagnostics

#ifdef _DEBUG
void CEx030204View::AssertValid() const
{
	CView::AssertValid();
}

void CEx030204View::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

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

/////////////////////////////////////////////////////////////////////////////
// CEx030204View message handlers

void CEx030204View::OnRButtonDown(UINT nFlags, CPoint point) 
{
	CMenuEx  menu;
	menu.CreatePopupMenu(); 
	menu.AppendMenuEx(MF_ENABLED,ID_FILE_NEW,"新建");
	ClientToScreen(&point);
 
	menu.TrackPopupMenu(TPM_LEFTBUTTON|TPM_LEFTALIGN,point.x,point.y,this);	
	CView::OnRButtonDown(nFlags, point);
}

⌨️ 快捷键说明

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