ex120800view.cpp
来自「深入浅出Visual C++入门进阶与应用实例 随书光盘 作者 何志丹」· C++ 代码 · 共 117 行
CPP
117 行
// EX120800View.cpp : implementation of the CEX120800View class
//
#include "stdafx.h"
#include "EX120800.h"
#include "EX120800Doc.h"
#include "EX120800View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEX120800View
IMPLEMENT_DYNCREATE(CEX120800View, CView)
BEGIN_MESSAGE_MAP(CEX120800View, CView)
//{{AFX_MSG_MAP(CEX120800View)
// 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, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEX120800View construction/destruction
CEX120800View::CEX120800View()
{
// TODO: add construction code here
}
CEX120800View::~CEX120800View()
{
}
BOOL CEX120800View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CEX120800View drawing
void CEX120800View::OnDraw(CDC* pDC)
{
char szSysDir[MAX_PATH + 1 ] ;
GetSystemDirectory(szSysDir,MAX_PATH);
//取得记事本的路径.注意:在某些操作系统上可能会出错.
CString strFileName = szSysDir + CString("\\notepad.exe");
SHFILEINFO stFileInfo ;
if( :: SHGetFileInfo(strFileName,0, &stFileInfo,sizeof(stFileInfo),SHGFI_ICON))
{
pDC ->DrawIcon(10,10,stFileInfo.hIcon);
}
//给出计算器的图标
HICON hIcon=:: ExtractIcon(AfxGetInstanceHandle(),"calc.exe",0);
if (hIcon &&hIcon!=(HICON)-1)
pDC->DrawIcon(40,40,hIcon);
}
/////////////////////////////////////////////////////////////////////////////
// CEX120800View printing
BOOL CEX120800View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CEX120800View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CEX120800View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CEX120800View diagnostics
#ifdef _DEBUG
void CEX120800View::AssertValid() const
{
CView::AssertValid();
}
void CEX120800View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CEX120800Doc* CEX120800View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEX120800Doc)));
return (CEX120800Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEX120800View message handlers
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?