友情提示:如果本网页打开太慢或显示不完整,请尝试鼠标右键“刷新”本网页!
富士康小说网 返回本书目录 加入书签 我的书架 我的书签 TXT全本下载 『收藏到我的浏览器』

深入浅出MFC第2版(PDF格式)-第115部分

快捷操作: 按键盘上方向键 ← 或 → 可快速上下翻页 按键盘上的 Enter 键可回到本书目录页 按键盘上方向键 ↑ 可回到本页顶部! 如果本书没有阅读完,想下次继续接着阅读,可使用上方 "收藏到我的浏览器" 功能 和 "加入书签" 功能!



                   #0042 

                   #0043  CScribbleApp theApp; 

                   #0044 

                   #0045  //////////////////////////////////////////////////////////////// 

                   #0046  // CScribbleApp initialization 

                   #0047 

                   #0048  BOOL CScribbleApp::InitInstance() 

                   #0049  { 

                   #0050          // Standard initialization 

                   #0051          // If you are not using these features and wish to reduce the size 

                   #0052          //  of your final executable; you should remove from the following 

                   #0053          //  the specific initialization routines you do not need。 

                   #0054 

                   #0055  #ifdef _AFXDLL 

                   #0056          Enable3dControls();  // Call this when using MFC in a shared DLL 

                   #0057  #else 

                   #0058          Enable3dControlsStatic();  // Call this when linking to MFC statically 

                   #0059  #endif 

                   #0060 

                   #0061         LoadStdProfileSettings();  // Load standard INI file options (including MRU) 

                   #0062 

                   #0063 

                   #0064          // Register the application's document templates。  Document templates 

                   #0065          //  serve as the connection between documents; frame windows and views。 



876 


…………………………………………………………Page 939……………………………………………………………

                                                   附錄B    Scribble Step5  完整原始碼 



#0066 

#0067          CMultiDocTemplate* pDocTemplate; 

#0068          pDocTemplate = new CMultiDocTemplate( 

#0069                  IDR_SCRIBBTYPE; 

#0070                  RUNTIME_CLASS(CScribbleDoc); 

#0071                  RUNTIME_CLASS(CChildFrame); // custom MDI child frame 

#0072                  RUNTIME_CLASS(CScribbleView)); 

#0073 

#0074          AddDocTemplate(pDocTemplate); 

#0075 

#0076          // create main MDI Frame window 

#0077          CMainFrame* pMainFrame = new CMainFrame; 

#0078          if (!pMainFrame…》LoadFrame(IDR_MAINFRAME)) 

#0079                  return FALSE; 

#0080          m_pMainWnd = pMainFrame; 

#0081 

#0082          // Enable drag/drop open。  We don't call this in Win32; since a 

#0083          //  document file extension wasn't chosen while running AppWizard。 

#0084          m_pMainWnd…》DragAcceptFiles(); 

#0085 

#0086          // Enable DDE Execute open 

#0087          EnableShellOpen(); 

#0088          RegisterShellFileTypes(TRUE); 

#0089 

#0090          // Parse mand line for standard shell mands; DDE; file open 

#0091          CmandLineInfo cmdInfo; 

#0092          ParsemandLine(cmdInfo); 

#0093 

#0094          // Dispatch mands specified on the mand line 

#0095          if (!ProcessShellmand(cmdInfo)) 

#0096                  return FALSE; 

#0097 

#0098 

#0099          // The main window has been initialized; so show and update it。 

#0100          pMainFrame…》ShowWindow(m_nCmdShow); 

#0101          pMainFrame…》UpdateWindow(); 

#0102 

#0103          return TRUE; 

#0104  } 

#0105 

#0106  ///////////////////////////////////////////////////////////////// 

#0107  // CAboutDlg dialog used for App About 

#0108 

#0109  class CAboutDlg : public CDialog 

#0110  { 

#0111  public: 



                                                                                     877 


…………………………………………………………Page 940……………………………………………………………

                   第五篇    附錄  



                   #0112          CAboutDlg(); 

                   #0113 

                   #0114  // Dialog Data 

                   #0115          //{{AFX_DATA(CAboutDlg) 

                   #0116          enum { IDD = IDD_ABOUTBOX }; 

                   #0117          //}}AFX_DATA 

                   #0118 

                   #0119          // ClassWizard generated virtual function overrides 

                   #0120          //{{AFX_VIRTUAL(CAboutDlg) 

                   #0121          protected: 

                   #0122          virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support 

                   #0123          //}}AFX_VIRTUAL 

                   #0124 

                   #0125  // Implementation 

                   #0126  protected: 

                   #0127          //{{AFX_MSG(CAboutDlg) 

                   #0128                  // No message handlers 

                   #0129          //}}AFX_MSG 

                   #0130          DECLARE_MESSAGE_MAP() 

                   #0131  }; 

                   #0132 

                   #0133  CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) 

                   #0134  { 

                   #0135          //{{AFX_DATA_INIT(CAboutDlg) 

                   #0136          //}}AFX_DATA_INIT 

                   #0137  } 

                   #0138 

                   #0139  void CAboutDlg::DoDataExchange(CDataExchange* pDX) 

                   #0140  { 

                   #0141          CDialog::DoDataExchange(pDX); 

                   #0142          //{{AFX_DATA_MAP(CAboutDlg) 

                   #0143          //}}AFX_DATA_MAP 

                   #0144  } 

                   #0145 

                   #0146  BEGIN_MESSAGE_MAP(CAboutDlg; CDialog) 

                   #0147          //{{AFX_MSG_MAP(CAboutDlg) 

                   #0148                  // No message handlers 

                   #0149          //}}AFX_MSG_MAP 

                   #0150  END_MESSAGE_MAP() 

                   #0151 

                   #0152  // App mand to run the dialog 

                   #0153  void CScribbleApp::OnAppAbout() 

                   #0154  { 

                   #0155          CAboutDlg aboutDlg; 

                   #0156          aboutDlg。DoModal(); 

                   #0157  } 



878 


…………………………………………………………Page 941……………………………………………………………

                                                   附錄B    Scribble Step5  完整原始碼 



MAINFRAME。H 



#0001  class CMainFrame : public CMDIFrameWnd 

#0002  { 

#0003          DECLARE_DYNAMIC(CMainFrame) 

#0004  public: 

#0005          CMainFrame(); 

#0006 

#0007  // Attributes 

#0008  public: 

#0009 

#0010  // Operations 

#0011  public: 

#0012 

#0013  // Overrides 

#0014          // ClassWizard generated virtual function overrides 

#0015          //{{AFX_VIRTUAL(CMainFrame) 

#0016          virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 

#0017          //}}AFX_VIRTUAL 

#0018 

#0019  // Implementation 

#0020  public: 

#0021          virtual ~CMainFrame(); 

#0022  #ifdef _DEBUG 

#0023          virtual void AssertValid() const; 

#0024          virtual void Dump(CDumpContext& dc) const; 

#0025  #endif 

#0026 

#0027  protected:  // control bar embedded members 

#0028          CStatusBar  m_wndStatusBar; 

#0029          CToolBar    m_wndToolBar; 

#0030 

#0031  // Generated message map functions 

#0032  protected: 

#0033          //{{AFX_MSG(CMainFrame) 

#0034          afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 

#0035            // NOTE the ClassWizard will add and remove member functions here。 

#0036            //    DO NOT EDIT what you see in these blocks of generated code! 

#0037          //}}AFX_MSG 

#0038          DECLARE_MESSAGE_MAP() 

#0039  }; 



                                                                                     879 


…………………………………………………………Page 942……………………………………………………………

                   第五篇    附錄  



                   MAINFRAME。CPP 



                   #0001  #include 〃stdafx。h〃 

                   #0002  #include 〃Scribble。h〃 

                   #0003 

                   #0004  #include 〃MainFrm。h〃 

                   #0005 

                   #0006  #ifdef _DEBUG 

                   #0007  #define new DEBUG_NEW 

                   #0008  #undef THIS_FILE 

                   #0009  static char THIS_FILE'' = __FILE__; 

                   #0010  #endif 

                   #0011 

                   #0012  /////////////////////////////////////////////////////////////// 

                   #0013  // CMainFrame 

                   #0014 

                   #0015  IMPLEMENT_DYNAMIC(CMainFrame; CMDIFrameWnd) 

                   #0016 

                   #0017  BEGIN_MESSAGE_MAP(CMainFrame; CMDIFrameWnd) 

                   #0018          //{{AFX_MSG_MAP(CMainFrame) 

                   #0019              // NOTE the ClassWizard will add and remove mapping macros here。 

                   #0020              //    DO NOT EDIT what you see in these blocks of generated code ! 

                   #0021          ON_WM_CREATE() 

                   #0022          //}}AFX_MSG_MAP 

                   #0023  END_MESSAGE_MAP() 

                   #0024 

                   #0025  static UINT indicators'' = 

                   #0026  { 

                   #0027          ID_SEPARATOR;           // status line indicator 

                   #0028          ID_INDICATOR_CAPS; 

                   #0029          ID_INDICATOR_NUM; 

                   #0030          ID_INDICATOR_SCRL; 

                   #0031  }; 

                   #0032 

                   #0033  ///////////////////////////////////////////////////////////////// 

                   #0034  // CMainFrame construction/destruction 

                   #0035 

                   #0036  CMainFrame::CMainFrame() 

                   #0037  { 

                   #0038          // TODO: add member initialization code here 

                   #0039 

                   #0040  } 

                   #0041 

                   #0042  CMainFrame::~CMainFrame() 

                   #0043  { 

                   #0044  } 



880 


…………………………………………………………Page 943……………………………………………………………

                                                   附錄B    Scribble Step5  完整原始碼 



#0045 

#0046  int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 

#0047  { 

#0048          if (CMDIFrameWnd::OnCreate(lpCreateStruct) == …1) 

#0049                  return …1; 

#0050 

#0051          if (!m_wndToolBar。Create(this) || 

#0052                  !m_wndToolBar。LoadToolBar(IDR_MAINFRAME)) 

#0053          { 

#0054                  TRACE0(〃Failed to create toolbarn〃); 

#0055                  return …1;      // fail to create 

#0056          } 

#0057 

#0058          if (!m_wndStatusBar。Create(this) || 

#0059                  !m_wndStatusBar。SetIndicators(indicators; 

#0060                    sizeof(indicators)/sizeof(UINT))) 

#0061          { 

#0062                  TRACE0(〃Failed to create status barn〃); 

#0063                  return …1;      // fail to create 

#0064          } 

#0065 

#0066          // TODO: Remove this if you don't want tool tips 

#0067          m_wndToolBar。SetBarStyle(m_wndToolBar。GetBarStyle() | 

#0068                  CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); 

#0069 

#0070          // TODO: Delete these three lines if you don't want the toolbar to 

#0071          //  be dockable 

#0072          m_wndToolBar。EnableDocking(CBRS_ALIGN_ANY); 

#0073          EnableDocking(CBRS_ALIGN_ANY); 

#0074          DockControlBar(&m_wndToolBar); 

#0075 

#0076 

#0077          return 0; 

#0078  } 

#0079 

#0080  BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) 

#0081  { 

#0082          // TODO: Modify the Window class or styles here by modifying 

#0083          //  the CREATESTRUCT cs 

#0084 

#0085          return CMDIFrameWnd::PreCreateWindow(cs); 

#0086  } 

#0087 

#0088  ///////////////////////////////////////////////////////////////// 

#0089  // CMainFrame diagnostics 

#0090 



                                                                                      881 


…………………………………………………………Page 944……………………………………………………………

                   第五篇    附錄  



                   #0091  #ifdef _DEBUG 

                   #0092  void CMainFrame::AssertValid() const 

                   #0093  { 

                   #0094          CMDIFrameWnd::AssertValid(); 

                   #0095  } 

                   #0096 

                   #0097  void CMainFrame::Dump(CDumpContext& dc) const 

                   #0098  { 

                   #0099          CMDIFrameWnd::Dump(dc); 

                   #0100  } 

                   #0101 

                   #0102  #endif //_DEBUG 

                   #0103 

                   #0104  ///////////////////////////////////////////////////////////////// 

                   #0105  // CMainFrame message handlers 



                   CHILDFRM。H 



                   #0001  class CChildFrame : public CMDIChildWnd 

                   #0002  { 

                   #0003          DECLARE_DYNCREATE(CChildFrame) 

                   #0004  public: 

                   #0005          CChildFrame(); 

                   #0006 

                   #0007  // Attributes 

                   #0008  protected: 

                   #0009          CSplitterWnd    m_wndSplitter; 

                   #0010  public: 

                   #0011 

                   #0012  // Operations 

                   #0013  public: 

                   #0014 

                   #0015  // Overrides 

                   #0016          // ClassWizard generated virtual function overrides 

                   #0017          //{{AFX_VIRTUAL(CChildFrame) 

                   #0018          public: 

                   #0019          virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 

                   #0020          protected: 

                   #0021     virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs; CCreateContext* pContext); 

                   #0022     //}}AFX_VIRTUAL 

                   #0023 

                   #0024  // Implementation 

                   #0025  public: 

                   #0026          virtual ~CChildFrame(); 

                   #0027  #ifdef _DEBUG 

                   #0028          virtual void AssertValid() const; 



882 


…………………………………………………………Page 945……………………………………………………………

                                                   附錄B    Scribble Step5  完整原始碼 



#0029          virtual void Dump(CDumpContext& dc) const; 

#0030  #endif 

#0031 

#0032  // Generated message map functions 

#0033  protected: 

#0034          //{{AFX_MSG(CChildFrame) 

#0035            // NOTE the ClassWizard will add and remove member functions here。 

#0036            //    DO NOT EDIT what you see in these blocks of generated code! 

#0037          //}}AFX_MSG 

#0038          DECLARE_MESSAGE_MAP() 

#0039  }; 



CHILDFRM。CPP 



#0001  #include 〃stdafx。h〃 

#000
返回目录 上一页 下一页 回到顶部 9 10
快捷操作: 按键盘上方向键 ← 或 → 可快速上下翻页 按键盘上的 Enter 键可回到本书目录页 按键盘上方向键 ↑ 可回到本页顶部!
温馨提示: 温看小说的同时发表评论,说出自己的看法和其它小伙伴们分享也不错哦!发表书评还可以获得积分和经验奖励,认真写原创书评 被采纳为精评可以获得大量金币、积分和经验奖励哦!