按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
————未阅读完?加入书签已便下次继续阅读!
本書的許多精心插圖,是令驚喜的方。圖解千言萬語,在這裡獲得最佳裕_。
871
…………………………………………………………Page 934……………………………………………………………
第五篇 附錄
鍋湯,要放多少沤泻茫坑邢矚g重口味,有雅好清如水。
本程式設計書籍,究竟要放多少碼,才能夠雅俗共賞,點頭?
關於這點,有兩種完全迥異的看法。第種看法似乎頗佔風,他們說書籍應該是解
釋程式的邏輯,程式的意念,程式設計的 呃 境界。因此出現在書的碼應該只能是
。。。 。。。
小小的、片段的、簡捷的。但凡有大落大落的碼出現,那便是不入流、難登大雅之
堂。我看過好多書評對於那種有著許多程式碼的書明嘲暗諷,甚而大加撻伐(呵呵,外
文期刊的書評很毒的)。
如果程式碼用來充篇幅,那就罵得好。
如果完整的碼用來給予完整的面觀,我就認為值得。
其實,程式碼是贅餘還是適得其所,完全視讀者的個情況而定。
Scribble 範例程式從第4章的 Step0 出發之後,陸陸續續只有片片斷斷的個個函式
碼。我認為有必要把本書所涵蓋的最後個版本 Step5 的完整原始碼列出,以為 Step0
之比對。
它來了。
抱怨程式碼太多的,可能是認為頁數多寡會反應在書籍售價。有些書是這樣。但這
本書,真的,我說,1000 頁或700 頁,都不會影響它的價格(與價值)。
872
…………………………………………………………Page 935……………………………………………………………
附錄B Scribble Step5 完整原始碼
附錄B
Scribble Step 5
完整原始碼
Scribble Step 5 是個擁有如功能的 MDI 塗鴉程式:
選單 利用滑鼠做塗鴉動作,
工具列 繪圖內容可存檔,亦可自檔案讀出。
子視窗縮小為圖示 同份 Document 開啟兩個 View 視窗 狀態列 分裂視窗
873
…………………………………………………………Page 936……………………………………………………………
第五篇 附錄
對話盒可設定繪筆粗細
列印與預樱А №撌住 ”眍^ Document 內容
SCRIBBLE。H
#0001 #ifndef __AFXWIN_H__
#0002 #error include 'stdafx。h' before including this file for PCH
#0003 #endif
#0004
#0005 #include 〃resource。h〃 // main symbols
#0006
#0007 /////////////////////////////////////////////////////////////////
#0008 // CScribbleApp:
874
…………………………………………………………Page 937……………………………………………………………
附錄B Scribble Step5 完整原始碼
#0009 // See Scribble。cpp for the implementation of this class
#0010 //
#0011
#0012 class CScribbleApp : public CWinApp
#0013 {
#0014 public:
#0015 CScribbleApp();
#0016
#0017 // Overrides
#0018 // ClassWizard generated virtual function overrides
#0019 //{{AFX_VIRTUAL(CScribbleApp)
#0020 public:
#0021 virtual BOOL InitInstance();
#0022 //}}AFX_VIRTUAL
#0023
#0024 // Implementation
#0025
#0026 //{{AFX_MSG(CScribbleApp)
#0027 afx_msg void OnAppAbout();
#0028 // NOTE the ClassWizard will add and remove member functions here。
#0029 // DO NOT EDIT what you see in these blocks of generated code !
#0030 //}}AFX_MSG
#0031 DECLARE_MESSAGE_MAP()
#0032 };
SCRIBBLE。CPP
#0001 #include 〃stdafx。h〃
#0002 #include 〃Scribble。h〃
#0003
#0004 #include 〃MainFrm。h〃
#0005 #include 〃ChildFrm。h〃
#0006 #include 〃ScribDoc。h〃
#0007 #include 〃ScribVw。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 // CScribbleApp
#0017
#0018 BEGIN_MESSAGE_MAP(CScribbleApp; CWinApp)
#0019 //{{AFX_MSG_MAP(CScribbleApp)
875
…………………………………………………………Page 938……………………………………………………………
第五篇 附錄
#0020 ON_MAND(ID_APP_ABOUT; OnAppAbout)
#0021 // NOTE the ClassWizard will add and remove mapping macros here。
#0022 // DO NOT EDIT what you see in these blocks of generated code!
#0023 //}}AFX_MSG_MAP
#0024 // Standard file based document mands
#0025 ON_MAND(ID_FILE_NEW; CWinApp::OnFileNew)
#0026 ON_MAND(ID_FILE_OPEN; CWinApp::OnFileOpen)
#0027 // Standard print setup mand
#0028 ON_MAND(ID_FILE_PRINT_SETUP; CWinApp::OnFilePrintSetup)
#0029 END_MESSAGE_MAP()
#0030
#0031 /////////////////////////////////////////////////////////////////
#0032 // CScribbleApp construction
#0033
#0034 CScribbleApp::CScribbleApp()
#0035 {
#0036 // TODO: add construction code here;
#0037 // Place all significant initialization in InitInstance
#0038 }
#0039
#0040 //////////////////////////////////////////////////////////////
#0041 // The one and only CScribbleApp object
#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(pDocT