Classview.docx
《Classview.docx》由会员分享,可在线阅读,更多相关《Classview.docx(19页珍藏版)》请在冰豆网上搜索。
Classview
类视图:
(classview)
//abc123.h:
mainheaderfilefortheABC123application
//
#if!
defined(AFX_ABC123_H__3B4378CC_7B68_4D9F_898D_E92DECF9326C__INCLUDED_)
#defineAFX_ABC123_H__3B4378CC_7B68_4D9F_898D_E92DECF9326C__INCLUDED_
#if_MSC_VER>1000
#pragmaonce
#endif//_MSC_VER>1000
#ifndef__AFXWIN_H__
#errorinclude'stdafx.h'beforeincludingthisfileforPCH
#endif
#include"resource.h"//mainsymbols
/////////////////////////////////////////////////////////////////////////////
//CAbc123App:
//Seeabc123.cppfortheimplementationofthisclass
//
classCAbc123App:
publicCWinApp
{
public:
CAbc123App();
//Overrides
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CAbc123App)
public:
virtualBOOLInitInstance();
//}}AFX_VIRTUAL
//Implementation
//{{AFX_MSG(CAbc123App)
afx_msgvoidOnAppAbout();
//NOTE-theClassWizardwilladdandremovememberfunctionshere.
//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
//MicrosoftVisualC++willinsertadditionaldeclarationsimmediatelybeforethepreviousline.
#endif//!
defined(AFX_ABC123_H__3B4378CC_7B68_4D9F_898D_E92DECF9326C__INCLUDED_)
//abc123Doc.h:
interfaceoftheCAbc123Docclass
//
/////////////////////////////////////////////////////////////////////////////
#if!
defined(AFX_ABC123DOC_H__3A5F1AB6_4336_465B_8842_8C74AF247DC8__INCLUDED_)
#defineAFX_ABC123DOC_H__3A5F1AB6_4336_465B_8842_8C74AF247DC8__INCLUDED_
#if_MSC_VER>1000
#pragmaonce
#endif//_MSC_VER>1000
classCAbc123Doc:
publicCDocument
{
protected:
//createfromserializationonly
CAbc123Doc();
DECLARE_DYNCREATE(CAbc123Doc)
//Attributes
public:
//Operations
public:
//Overrides
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CAbc123Doc)
public:
virtualBOOLOnNewDocument();
virtualvoidSerialize(CArchive&ar);
//}}AFX_VIRTUAL
//Implementation
public:
virtual~CAbc123Doc();
#ifdef_DEBUG
virtualvoidAssertValid()const;
virtualvoidDump(CDumpContext&dc)const;
#endif
protected:
//Generatedmessagemapfunctions
protected:
//{{AFX_MSG(CAbc123Doc)
//NOTE-theClassWizardwilladdandremovememberfunctionshere.
//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
//MicrosoftVisualC++willinsertadditionaldeclarationsimmediatelybeforethepreviousline.
#endif//!
defined(AFX_ABC123DOC_H__3A5F1AB6_4336_465B_8842_8C74AF247DC8__INCLUDED_)
//abc123View.h:
interfaceoftheCAbc123Viewclass
//
/////////////////////////////////////////////////////////////////////////////
#if!
defined(AFX_ABC123VIEW_H__A0886DF3_EA34_45BA_B194_3812820C3D58__INCLUDED_)
#defineAFX_ABC123VIEW_H__A0886DF3_EA34_45BA_B194_3812820C3D58__INCLUDED_
#if_MSC_VER>1000
#pragmaonce
#endif//_MSC_VER>1000
classCAbc123View:
publicCView
{
protected:
//createfromserializationonly
CAbc123View();
DECLARE_DYNCREATE(CAbc123View)
//Attributes
public:
CAbc123Doc*GetDocument();
//Operations
public:
//Overrides
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CAbc123View)
public:
virtualvoidOnDraw(CDC*pDC);//overriddentodrawthisview
virtualBOOLPreCreateWindow(CREATESTRUCT&cs);
protected:
virtualBOOLOnPreparePrinting(CPrintInfo*pInfo);
virtualvoidOnBeginPrinting(CDC*pDC,CPrintInfo*pInfo);
virtualvoidOnEndPrinting(CDC*pDC,CPrintInfo*pInfo);
//}}AFX_VIRTUAL
//Implementation
public:
virtual~CAbc123View();
#ifdef_DEBUG
virtualvoidAssertValid()const;
virtualvoidDump(CDumpContext&dc)const;
#endif
protected:
//Generatedmessagemapfunctions
protected:
//{{AFX_MSG(CAbc123View)
//NOTE-theClassWizardwilladdandremovememberfunctionshere.
//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef_DEBUG//debugversioninabc123View.cpp
inlineCAbc123Doc*CAbc123View:
:
GetDocument()
{return(CAbc123Doc*)m_pDocument;}
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
//MicrosoftVisualC++willinsertadditionaldeclarationsimmediatelybeforethepreviousline.
#endif//!
defined(AFX_ABC123VIEW_H__A0886DF3_EA34_45BA_B194_3812820C3D58__INCLUDED_)
//abc123.cpp:
Definestheclassbehaviorsfortheapplication.
//
#include"stdafx.h"
#include"abc123.h"
#include"MainFrm.h"
#include"abc123Doc.h"
#include"abc123View.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CAbc123App
BEGIN_MESSAGE_MAP(CAbc123App,CWinApp)
//{{AFX_MSG_MAP(CAbc123App)
ON_COMMAND(ID_APP_ABOUT,OnAppAbout)
//NOTE-theClassWizardwilladdandremovemappingmacroshere.
//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!
//}}AFX_MSG_MAP
//Standardfilebaseddocumentcommands
ON_COMMAND(ID_FILE_NEW,CWinApp:
:
OnFileNew)
ON_COMMAND(ID_FILE_OPEN,CWinApp:
:
OnFileOpen)
//Standardprintsetupcommand
ON_COMMAND(ID_FILE_PRINT_SETUP,CWinApp:
:
OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CAbc123Appconstruction
CAbc123App:
:
CAbc123App()
{
//TODO:
addconstructioncodehere,
//PlaceallsignificantinitializationinInitInstance
}
/////////////////////////////////////////////////////////////////////////////
//TheoneandonlyCAbc123Appobject
CAbc123ApptheApp;
/////////////////////////////////////////////////////////////////////////////
//CAbc123Appinitialization
BOOLCAbc123App:
:
InitInstance()
{
AfxEnableControlContainer();
//Standardinitialization
//Ifyouarenotusingthesefeaturesandwishtoreducethesize
//ofyourfinalexecutable,youshouldremovefromthefollowing
//thespecificinitializationroutinesyoudonotneed.
#ifdef_AFXDLL
Enable3dControls();//CallthiswhenusingMFCinasharedDLL
#else
Enable3dControlsStatic();//CallthiswhenlinkingtoMFCstatically
#endif
//Changetheregistrykeyunderwhichoursettingsarestored.
//TODO:
Youshouldmodifythisstringtobesomethingappropriate
//suchasthenameofyourcompanyororganization.
SetRegistryKey(_T("LocalAppWizard-GeneratedApplications"));
LoadStdProfileSettings();//LoadstandardINIfileoptions(includingMRU)
//Registertheapplication'sdocumenttemplates.Documenttemplates
//serveastheconnectionbetweendocuments,framewindowsandviews.
CSingleDocTemplate*pDocTemplate;
pDocTemplate=newCSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CAbc123Doc),
RUNTIME_CLASS(CMainFrame),//mainSDIframewindow
RUNTIME_CLASS(CAbc123View));
AddDocTemplate(pDocTemplate);
//Parsecommandlineforstandardshellcommands,DDE,fileopen
CCommandLineInfocmdInfo;
ParseCommandLine(cmdInfo);
//Dispatchcommandsspecifiedonthecommandline
if(!
ProcessShellCommand(cmdInfo))
returnFALSE;
//Theoneandonlywindowhasbeeninitialized,soshowandupdateit.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
returnTRUE;
}
/////////////////////////////////////////////////////////////////////////////
//CAboutDlgdialogusedforAppAbout
classCAboutDlg:
publicCDialog
{
public:
CAboutDlg();
//DialogData
//{{AFX_DATA(CAboutDlg)
enum{IDD=IDD_ABOUTBOX};
//}}AFX_DATA
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport
//}}AFX_VIRTUAL
//Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//Nomessagehandlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg:
:
CAboutDlg():
CDialog(CAboutDlg:
:
IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
voidCAboutDlg:
:
DoDataExchange(CDataExchange*pDX)
{
CDialog:
:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//Nomessagehandlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//Appcommandtorunthedialog
voidCAbc123App:
:
OnAppAbout()
{
CAboutDlgaboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
//CAbc123Appmessagehandlers
//MainFrm.h:
interfaceoftheCMainFrameclass
//
/////////////////////////////////////////////////////////////////////////////
#if!
defined(AFX_MAINFRM_H__A373B4D9_5D82_4272_B153_7D2D3494D725__INCLUDED_)
#defineAFX_MAINFRM_H__A373B4D9_5D82_4272_B153_7D2D3494D725__INCLUDED_
#if_MSC_VER>1000
#pragmaonce
#endif//_MSC_VER>1000
classCMainFrame:
publicCFrameWnd
{
protected:
//createfromserializationonly
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
//Attributes
public:
//Operations
public:
//Overrides
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CMainFrame)
virtualBOOLPreCreateWindow(CREATESTRUCT&cs);
//}}AFX_VIRTUAL
//Implementation
public:
virtual~CMainFrame();
#ifdef_DEBUG
virtualvoidAssertValid()const;
virtualvoidDump(CDumpContext&dc)const;
#endif
protected:
//controlbarembeddedmembers
CStatusBarm_wndStatusBar;
CToolBarm_wndToolBar;
//Generatedmessagemapfunctions
protected:
//{{AFX_MSG(CMainFrame)
afx_msgintOnCreate(LPCREATESTRUCTlpCreateStruct);
//NOTE-theClassWizardwilladdandremovememberfunctionshere.
//DONOTEDITwhatyouseeintheseblocksofgenerat