按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 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