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

📄 funptrview.cpp

📁 对指针的使用做测试的源码
💻 CPP
字号:
// FunPtrView.cpp : implementation of the CFunPtrView class
//

#include "stdafx.h"
#include "FunPtr.h"

#include "FunPtrDoc.h"
#include "FunPtrView.h"

/// 8 引入调用类, 让他通过成员函数指针调用吧
#include "Call.h"

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

/////////////////////////////////////////////////////////////////////////////
// CFunPtrView

IMPLEMENT_DYNCREATE(CFunPtrView, CView)

BEGIN_MESSAGE_MAP(CFunPtrView, CView)
	//{{AFX_MSG_MAP(CFunPtrView)
	ON_WM_LBUTTONDOWN()
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CFunPtrView construction/destruction

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

}

CFunPtrView::~CFunPtrView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CFunPtrView drawing

void CFunPtrView::OnDraw(CDC* pDC)
{
	CFunPtrDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	pDC->TextOut(0,0,"单击左键通过类的带有类函数指针的成员函数调用另外一个类的成员函数");
	pDC->TextOut(0,30,"一共9步, 在代码搜索'/// '找找看都需要哪些操作");
}

/////////////////////////////////////////////////////////////////////////////
// CFunPtrView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CFunPtrView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CFunPtrView message handlers

void CFunPtrView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default

	/// 9 看好了,这是最后一步了,就要调用了
	CCall Call;
	int nReturn = Call.CallClassFunByPtr(CFun::GeneralFun,"呵呵,成功调用了吧");
	
	CView::OnLButtonDown(nFlags, point);
}

⌨️ 快捷键说明

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