友情提示:如果本网页打开太慢或显示不完整,请尝试鼠标右键“刷新”本网页!
深入浅出MFC第2版(PDF格式)-第40部分
快捷操作: 按键盘上方向键 ← 或 → 可快速上下翻页 按键盘上的 Enter 键可回到本书目录页 按键盘上方向键 ↑ 可回到本页顶部! 如果本书没有阅读完,想下次继续接着阅读,可使用上方 "收藏到我的浏览器" 功能 和 "加入书签" 功能!
#0004
#0005 #include 〃stdafx。h〃
SCRIBBLE。CPP
#0001 // Scribble。cpp : Defines the class behaviors for the application。
#0002 //
#0003
#0004 #include 〃stdafx。h〃
#0005 #include 〃Scribble。h〃
#0006
#0007 #include 〃MainFrm。h〃
#0008 #include 〃ChildFrm。h〃
#0009 #include 〃ScribbleDoc。h〃
#0010 #include 〃ScribbleView。h〃
#0011
#0012 #ifdef _DEBUG
#0013 #define new DEBUG_NEW
#0014 #undef THIS_FILE
#0015 static char THIS_FILE'' = __FILE__;
#0016 #endif
#0017
276
…………………………………………………………Page 339……………………………………………………………
第4章 Visual C++ 整合性軟體開發環境
#0018 /////////////////////////////////////////////////////////////////
#0019 // CScribbleApp
#0020
#0021 BEGIN_MESSAGE_MAP(CScribbleApp; CWinApp)
#0022 //{{AFX_MSG_MAP(CScribbleApp)
#0023 ON_MAND(ID_APP_ABOUT; OnAppAbout)
#0024 // NOTE the ClassWizard will add and remove mapping macros here。
#0025 // DO NOT EDIT what you see in these blocks of generated code!
#0026 //}}AFX_MSG_MAP
#0027 // Standard file based document mands
#0028 ON_MAND(ID_FILE_NEW; CWinApp::OnFileNew)
#0029 ON_MAND(ID_FILE_OPEN; CWinApp::OnFileOpen)
#0030 // Standard print setup mand
#0031 ON_MAND(ID_FILE_PRINT_SETUP; CWinApp::OnFilePrintSetup)
#0032 END_MESSAGE_MAP()
#0033
#0034 /////////////////////////////////////////////////////////////////
#0035 // CScribbleApp construction
#0036
#0037 CScribbleApp::CScribbleApp()
#0038 {
#0039 // TODO: add construction code here;
#0040 // Place all significant initialization in InitInstance
#0041 }
#0042
#0043 /////////////////////////////////////////////////////////////////
#0044 // The one and only CScribbleApp object
#0045
#0046 CScribbleApp theApp;
#0047
#0048 /////////////////////////////////////////////////////////////////
#0049 // CScribbleApp initialization
#0050
#0051 BOOL CScribbleApp::InitInstance()
#0052 {
#0053 // Standard initialization
#0054 // If you are not using these features and wish to reduce the size
#0055 // of your final executable; you should remove from the following
#0056 // the specific initialization routines you do not need。
#0057
#0058 #ifdef _AFXDLL
#0059 Enable3dControls(); // Call this when using MFC in a shared DLL
#0060 #else
#0061 Enable3dControlsStatic(); // Call this when linking to MFC statically
#0062 #endif
#0063
277
…………………………………………………………Page 340……………………………………………………………
第篇 欲善工事先利其器
#0064 // 侯俊杰注:0065~0068 为Visual C++ 5。0 新增
#0065 // Change the registry key under which our settings are stored。
#0066 // You should modify this string to be something appropriate
#0067 // such as the name of your pany or organization。
#0068 SetRegistryKey(_T(〃Local AppWizard…Generated Applications〃));
#0069
#0070 LoadStdProfileSettings(); // Load std INI file options (including MRU)
#0071
#0072 // Register the application's document templates。 Document templates
#0073 // serve as the connection between documents; frame windows and views。
#0074
#0075 CMultiDocTemplate* pDocTemplate;
#0076 pDocTemplate = new CMultiDocTemplate(
#0077 IDR_SCRIBTYPE;
#0078 RUNTIME_CLASS(CScribbleDoc);
#0079 RUNTIME_CLASS(CChildFrame); // custom MDI child frame
#0080 RUNTIME_CLASS(CScribbleView));
#0081 AddDocTemplate(pDocTemplate);
#0082
#0083 // create main MDI Frame window
#0084 CMainFrame* pMainFrame = new CMainFrame;
#0085 if (!pMainFrame…》LoadFrame(IDR_MAINFRAME))
#0086 return FALSE;
#0087 m_pMainWnd = pMainFrame;
#0088
#0089 // Enable drag/drop open
#0090 m_pMainWnd…》DragAcceptFiles();
#0091
#0092 // Enable DDE Execute open
#0093 EnableShellOpen();
#0094 RegisterShellFileTypes(TRUE);
#0095
#0096 // Parse mand line for standard shell mands; DDE; file open
#0097 CmandLineInfo cmdInfo;
#0098 ParsemandLine(cmdInfo);
#0099
#0100 // Dispatch mands specified on the mand line
#0101 if (!ProcessShellmand(cmdInfo))
#0102 return FALSE;
#0103
#0104 // The main window has been initialized; so show and update it。
#0105 pMainFrame…》ShowWindow(m_nCmdShow);
#0106 pMainFrame…》UpdateWindow();
#0107
#0108 return TRUE;
#0109 }
278
…………………………………………………………Page 341……………………………………………………………
第4章 Visual C++ 整合性軟體開發環境
#0110
#0111 /////////////////////////////////////////////////////////////////
#0112 // CAboutDlg dialog used for App About
#0113
#0114 class CAboutDlg : public CDialog
#0115 {
#0116 public:
#0117 CAboutDlg();
#0118
#0119 // Dialog Data
#0120 //{{AFX_DATA(CAboutDlg)
#0121 enum { IDD = IDD_ABOUTBOX };
#0122 //}}AFX_DATA
#0123
#0124 // ClassWizard generated virtual function overrides
#0125 //{{AFX_VIRTUAL(CAboutDlg)
#0126 protected:
#0127 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
#0128 //}}AFX_VIRTUAL
#0129
#0130 // Implementation
#0131 protected:
#0132 //{{AFX_MSG(CAboutDlg)
#0133 // No message handlers
#0134 //}}AFX_MSG
#0135 DECLARE_MESSAGE_MAP()
#0136 };
#0137
#0138 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
#0139 {
#0140 //{{AFX_DATA_INIT(CAboutDlg)
#0141 //}}AFX_DATA_INIT
#0142 }
#0143
#0144 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
#0145 {
#0146 CDialog::DoDataExchange(pDX);
#0147 //{{AFX_DATA_MAP(CAboutDlg)
#0148 //}}AFX_DATA_MAP
#0149 }
#0150
#0151 BEGIN_MESSAGE_MAP(CAboutDlg; CDialog)
#0152 //{{AFX_MSG_MAP(CAboutDlg)
#0153 // No message handlers
#0154 //}}AFX_MSG_MAP
#0155 END_MESSAGE_MAP()
279
…………………………………………………………Page 342……………………………………………………………
第篇 欲善工事先利其器
#0156
#0157 // App mand to run the dialog
#0158 void CScribbleApp::OnAppAbout()
#0159 {
#0160 CAboutDlg aboutDlg;
#0161 aboutDlg。DoModal();
#0162 }
#0163
#0164 /////////////////////////////////////////////////////////////////
#0165 // CScribbleApp mands
MAINFRM。CPP
#0001 // MainFrm。cpp : implementation of the CMainFrame class
#0002 //
#0003
#0004 #include 〃stdafx。h〃
#0005 #include 〃Scribble。h〃
#0006
#0007 #include 〃MainFrm。h〃
#0008
#0009 #ifdef _DEBUG
#0010 #define new DEBUG_NEW
#0011 #undef THIS_FILE
#0012 static char THIS_FILE'' = __FILE__;
#0013 #endif
#0014
#0015 /////////////////////////////////////////////////////////////////
#0016 // CMainFrame
#0017
#0018 IMPLEMENT_DYNAMIC(CMainFrame; CMDIFrameWnd)
#0019
#0020 BEGIN_MESSAGE_MAP(CMainFrame; CMDIFrameWnd)
#0021 //{{AFX_MSG_MAP(CMainFrame)
#0022 // NOTE the ClassWizard will add and remove mapping macros here。
#0023 // DO NOT EDIT what you see in these blocks of generated code !
#0024 ON_WM_CREATE()
#0025 //}}AFX_MSG_MAP
#0026 END_MESSAGE_MAP()
#0027
#0028 static UINT indicators'' =
#0029 {
#0030 ID_SEPARATOR; // status line indicator
#0031 ID_INDICATOR_CAPS;
#0032 ID_INDICATOR_NUM;
#0033 ID_INDICATOR_SCRL;
280
…………………………………………………………Page 343……………………………………………………………
第4章 Visual C++ 整合性軟體開發環境
#0034 };
#0035
#0036 /////////////////////////////////////////////////////////////////
#0037 // CMainFrame construction/destruction
#0038
#0039 CMainFrame::CMainFrame()
#0040 {
#0041 // TODO: add member initialization code here
#0042
#0043 }
#0044
#0045 CMainFrame::~CMainFrame()
#0046 {
#0047 }
#0048
#0049 int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
#0050 {
#0051 if (CMDIFrameWnd::OnCreate(lpCreateStruct) == …1)
#0052 return …1;
#0053
#0054 if (!m_wndToolBar。Create(this) ||
#0055 !m_wndToolBar。LoadToolBar(IDR_MAINFRAME))
#0056 {
#0057 TRACE0(〃Failed to create toolbarn〃);
#0058 return …1; // fail to create
#0059 }
#0060
#0061 if (!m_wndStatusBar。Create(this) ||
#0062 !m_wndStatusBar。SetIndicators(indicators;
#0063 sizeof(indicators)/sizeof(UINT)))
#0064 {
#0065 TRACE0(〃Failed to create status barn〃);
#0066 return …1; // fail to create
#0067 }
#0068
#0069 // TODO: Remove this if you don't want tool tips or a resizeable toolbar
#0070 m_wndToolBar。SetBarStyle(m_wndToolBar。GetBarStyle() |
#0071 CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
#0072
#0073 // TODO: Delete these three lines if you don't want the toolbar to
#0074 // be dockable
#0075 m_wndToolBar。EnableDocking(CBRS_ALIGN_ANY);
#0076 EnableDocking(CBRS_ALIGN_ANY);
#0077 DockControlBar(&m_wndToolBar);
#0078
#0079 return 0;
281
…………………………………………………………Page 344……………………………………………………………
第篇 欲善工事先利其器
#0080 }
#0081
#0082 BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
#0083 {
#0084 // TODO: Modify the Window class or styles here by modifying
#0085 // the CREATESTRUCT cs
#0086
#0087 return CMDIFrameWnd::PreCreateWindow(cs);
#0088 }
#0089
#0090 /////////////////////////////////////////////////////////////////
#0091 // CMainFrame diagnostics
#0092
#0093 #ifdef _DEBUG
#0094 void CMainFrame::AssertValid() const
#0095 {
#0096 CMDIFrameWnd::AssertValid();
#0097 }
#0098
#0099 void CMainFrame::Dump(CDumpContext& dc) const
#0100 {
#0101 CMDIFrameWnd::Dump(dc);
#0102 }
#0103
#0104 #endif //_DEBUG
#0105
#0106 /////////////////////////////////////////////////////////////////
#0107 // CMainFrame message handlers
CHILDFRM。CPP
#0001 // ChildFrm。cpp : implementation of the CChildFrame class
#0002 //
#0003
#0004 #include 〃stdafx。h〃
#0005 #include 〃Scribble。h〃
#0006
#0007 #include 〃ChildFrm。h〃
#0008
#0009 #ifdef _DEBUG
#0010 #define new DEBUG_NEW
#0011 #undef THIS_FILE
#0012 static char THIS_FILE'' = __FILE__;
#0013 #endif
#0014
#0015 /////////////////////////////////////////////////////////////////
282
…………………………………………………………Page 345……………………………………………………………
第4章 Visual C++ 整合性軟體開發環境
#0016 // CChildFrame
#0017
#0018 IMPLEMENT_DYNCREATE(CChildFrame; CMDIChildWnd)
#0019
#0020 BEGIN_MESSAGE_MAP(CChildFrame; CMDIChildWnd)
#0021 //{{AFX_MSG_MAP(CChildFrame)
#0022 // NOTE the ClassWizard will add and remove mapping macros here。
#0023 // DO NOT EDIT what you see in these blocks of generated code !
#0024 //}}AFX_MSG_MAP
#0025 END_MESSAGE_MAP()
#0026
#0027 /////////////////////////////////////////////////////////////////
#0028 // CChildFrame construction/destruction
#0029
#0030 CChildFrame::CChildFrame()
#0031 {
#0032 // TODO: add member initialization code here
#0033
#0034 }
#0035
#0036 CChildFrame::~CChildFrame()
#0037 {
#0038 }
#0039
#0040 BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
#0041 {
#0042 // TODO: Modify the Window class or styles here by modifying
#0043 // the CREATESTRUCT cs
#0044
#0045 return CMDIChildWnd::PreCreateWindow(cs);
#0046 }
#0047
#0048 //////////////////////////////////////////////////////////////
快捷操作: 按键盘上方向键 ← 或 → 可快速上下翻页 按键盘上的 Enter 键可回到本书目录页 按键盘上方向键 ↑ 可回到本页顶部!
温馨提示: 温看小说的同时发表评论,说出自己的看法和其它小伙伴们分享也不错哦!发表书评还可以获得积分和经验奖励,认真写原创书评 被采纳为精评可以获得大量金币、积分和经验奖励哦!