深入浅出MFC第2版(PDF格式)-第51部分
按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
————未阅读完?加入书签已便下次继续阅读!
#0020
#0021 BOOL CWnd::Create()
#0022 {
#0023 cout pfn;
#0062 // otherwise should call DefWindowProc。
#0063 }
#0064
#0065 LRESULT CWnd::DefWindowProc(UINT message; WPARAM wParam; LPARAM lParam)
209
…………………………………………………………Page 272……………………………………………………………
第篇 勿在浮砂築高台
#0066 {
#0067 return TRUE;
#0068 }
#0069
#0070 BOOL CWnd::Onmand(WPARAM wParam; LPARAM lParam)
#0071 {
#0072 // 。。。
#0073 return OnCmdMsg(0; 0);
#0074 }
#0075
#0076 BOOL CFrameWnd::Onmand(WPARAM wParam; LPARAM lParam)
#0077 {
#0078 // 。。。
#0079 // route as normal mand
#0080 return CWnd::Onmand(wParam; lParam);
#0081 }
#0082
#0083 BOOL CFrameWnd::Create()
#0084 {
#0085 cout OnCmdMsg(nID; nCode))
#0115 return TRUE;
#0116
#0117 return FALSE;
#0118 }
#0119
#0120 BOOL CDocument::OnCmdMsg(UINT nID; int nCode)
#0121 {
#0122 if (CCmdTarget::OnCmdMsg(nID; nCode))
#0123 return TRUE;
#0124
#0125 return FALSE;
#0126 }
#0127
#0128 BOOL CView::OnCmdMsg(UINT nID; int nCode)
#0129 {
#0130 if (CWnd::OnCmdMsg(nID; nCode))
#0131 return TRUE;
#0132
#0133 BOOL bHandled = FALSE;
#0134 bHandled = m_pDocument…》OnCmdMsg(nID; nCode);
#0135 return bHandled;
#0136 }
#0137
#0138 AFX_MSGMAP* CCmdTarget::GetMessageMap() const
#0139 {
#0140 return &CCmdTarget::messageMap;
#0141 }
#0142
#0143 AFX_MSGMAP CCmdTarget::messageMap =
#0144 {
#0145 NULL;
#0146 &CCmdTarget::_messageEntries'0'
#0147 };
#0148
#0149 AFX_MSGMAP_ENTRY CCmdTarget::_messageEntries'' =
#0150 {
#0151
#0152 { 0; 0; CCmdTargetid; 0; AfxSig_end; 0 }
#0153 };
#0154
#0155 BEGIN_MESSAGE_MAP(CWnd; CCmdTarget)
#0156 ON_MAND(CWndid; 0)
#0157 END_MESSAGE_MAP()
211
…………………………………………………………Page 274……………………………………………………………
第篇 勿在浮砂築高台
#0158
#0159 BEGIN_MESSAGE_MAP(CFrameWnd; CWnd)
#0160 ON_MAND(CFrameWndid; 0)
#0161 END_MESSAGE_MAP()
#0162
#0163 BEGIN_MESSAGE_MAP(CDocument; CCmdTarget)
#0164 ON_MAND(CDocumentid; 0)
#0165 END_MESSAGE_MAP()
#0166
#0167 BEGIN_MESSAGE_MAP(CView; CWnd)
#0168 ON_MAND(CViewid; 0)
#0169 END_MESSAGE_MAP()
#0170
#0171 BEGIN_MESSAGE_MAP(CWinApp; CCmdTarget)
#0172 ON_MAND(CWinAppid; 0)
#0173 END_MESSAGE_MAP()
#0174
#0175 CWinApp* AfxGetApp()
#0176 {
#0177 return theApp。m_pCurrentWinApp;
#0178 }
#0179
#0180 LRESULT AfxWndProc(HWND hWnd; UINT nMsg; WPARAM wParam; LPARAM lParam;
#0181 CWnd *pWnd) // last parameter pWnd is added by JJHou。
#0182 {
#0183 //。。。
#0184 return AfxCallWndProc(pWnd; hWnd; nMsg; wParam; lParam);
#0185 }
#0186
#0187 LRESULT AfxCallWndProc(CWnd* pWnd; HWND hWnd; UINT nMsg;
WPARAM wParam; LPARAM lParam)
#0188 {
#0189 LRESULT lResult = pWnd…》WindowProc(nMsg; wParam; lParam);
#0190 return lResult;
#0191 }
MY。H
#0001 #include
#0002 #include 〃mfc。h〃
#0003
#0004 class CMyWinApp : public CWinApp
#0005 {
#0006 public:
#0007 CMyWinApp::CMyWinApp() {
#0008 }
212
…………………………………………………………Page 275……………………………………………………………
第3章 MFC 六大關鍵技術之模擬
#0009 CMyWinApp::~CMyWinApp() {
#0010 }
#0011 virtual BOOL InitInstance();
#0012 DECLARE_MESSAGE_MAP()
#0013 };
#0014
#0015 class CMyFrameWnd : public CFrameWnd
#0016 {
#0017 public:
#0018 CMyFrameWnd();
#0019 ~CMyFrameWnd() {
#0020 }
#0021 DECLARE_MESSAGE_MAP()
#0022 };
#0023
#0024 class CMyDoc : public CDocument
#0025 {
#0026 public:
#0027 CMyDoc::CMyDoc() {
#0028 }
#0029 CMyDoc::~CMyDoc() {
#0030 }
#0031 DECLARE_MESSAGE_MAP()
#0032 };
#0033
#0034 class CMyView : public CView
#0035 {
#0036 public:
#0037 CMyView::CMyView() {
#0038 }
#0039 CMyView::~CMyView() {
#0040 }
#0041 DECLARE_MESSAGE_MAP()
#0042 };
MY。CPP
#0001 #include 〃my。h〃
#0002
#0003 CMyWinApp theApp; // global object
#0004
#0005 BOOL CMyWinApp::InitInstance()
#0006 {
#0007 cout