友情提示:如果本网页打开太慢或显示不完整,请尝试鼠标右键“刷新”本网页!
深入浅出MFC第2版(PDF格式)-第46部分
快捷操作: 按键盘上方向键 ← 或 → 可快速上下翻页 按键盘上的 Enter 键可回到本书目录页 按键盘上方向键 ↑ 可回到本页顶部! 如果本书没有阅读完,想下次继续接着阅读,可使用上方 "收藏到我的浏览器" 功能 和 "加入书签" 功能!
#0164 CDocument::~CDocument() {
#0165 }
#0166
#0167 virtual BOOL OnCmdMsg(UINT nID; int nCode);
#0168
#0169 DECLARE_MESSAGE_MAP()
#0170 };
#0171
#0172 class CWnd : public CCmdTarget
#0173 {
#0174 public:
#0175 CWnd::CWnd() {
#0176 }
#0177 CWnd::~CWnd() {
#0178 }
206
…………………………………………………………Page 269……………………………………………………………
第3章 MFC 六大關鍵技術之模擬
#0179
#0180 virtual BOOL Create();
#0181 BOOL CreateEx();
#0182 virtual BOOL PreCreateWindow();
#0183 virtual LRESULT WindowProc(UINT nMsg; WPARAM wParam; LPARAM lParam);
#0184 virtual LRESULT DefWindowProc(UINT message; WPARAM wParam; LPARAM lParam);
#0185 virtual BOOL Onmand(WPARAM wParam; LPARAM lParam);
#0186
#0187 DECLARE_MESSAGE_MAP()
#0188 };
#0189
#0190 class CView;
#0191
#0192 class CFrameWnd : public CWnd
#0193 {
#0194 public:
#0195 CView* m_pViewActive; // current active view
#0196
#0197 public:
#0198 CFrameWnd::CFrameWnd() {
#0199 }
#0200 CFrameWnd::~CFrameWnd() {
#0201 }
#0202 BOOL Create();
#0203 CView* GetActiveView() const;
#0204 virtual BOOL PreCreateWindow();
#0205 virtual BOOL Onmand(WPARAM wParam; LPARAM lParam);
#0206 virtual BOOL OnCmdMsg(UINT nID; int nCode);
#0207
#0208 DECLARE_MESSAGE_MAP()
#0209
#0210 friend CView;
#0211 };
#0212
#0213 class CView : public CWnd
#0214 {
#0215 public:
#0216 CDocument* m_pDocument;
#0217
#0218 public:
#0219 CView::CView() {
#0220 }
#0221 CView::~CView() {
#0222 }
#0223
#0224 virtual BOOL OnCmdMsg(UINT nID; int nCode);
207
…………………………………………………………Page 270……………………………………………………………
第篇 勿在浮砂築高台
#0225
#0226 DECLARE_MESSAGE_MAP()
#0227
#0228 friend CFrameWnd;
#0229 };
#0230
#0231 // global function
#0232 CWinApp* AfxGetApp();
#0233 LRESULT AfxWndProc(HWND hWnd; UINT nMsg; WPARAM wParam; LPARAM lParam;
#0234 CWnd* pWnd); // last param。 pWnd is added by JJHOU。
#0235 LRESULT AfxCallWndProc(CWnd* pWnd; HWND hWnd; UINT nMsg; WPARAM wParam;
#0236 LPARAM lParam);
AFXMSG_。H
#0001 enum AfxSig
#0002 {
#0003 AfxSig_end = 0; // 'marks end of message map'
#0004 AfxSig_vv;
#0005 };
#0006
#0007 #define ON_MAND(id; memberFxn)
#0008 { WM_MAND; 0; (WORD)id; (WORD)id; AfxSig_vv; (AFX_PMSG)memberFxn };
MFC。CPP
#0001 #include 〃my。h〃 // 原该包含mfc。h 就好,但为了extern CMyWinApp 所以 。。。
#0002
#0003 extern CMyWinApp theApp;
#0004 extern void printlpEntries(AFX_MSGMAP_ENTRY* lpEntry);
#0005
#0006 BOOL CCmdTarget::OnCmdMsg(UINT nID; int nCode)
#0007 {
#0008 // Now look through message map to see if it applies to us
#0009 AFX_MSGMAP* pMessageMap;
#0010 AFX_MSGMAP_ENTRY* lpEntry;
#0011 for (pMessageMap = GetMessageMap(); pMessageMap != NULL;
#0012 pMessageMap = pMessageMap…》pBaseMessageMap)
#0013 {
#0014 lpEntry = pMessageMap…》lpEntries;
#0015 printlpEntries(lpEntry);
#0016 }
#0017
#0018 return FALSE; // not handled
#0019 }
208
…………………………………………………………Page 271……………………………………………………………
第3章 MFC 六大關鍵技術之模擬
#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
快捷操作: 按键盘上方向键 ← 或 → 可快速上下翻页 按键盘上的 Enter 键可回到本书目录页 按键盘上方向键 ↑ 可回到本页顶部!
温馨提示: 温看小说的同时发表评论,说出自己的看法和其它小伙伴们分享也不错哦!发表书评还可以获得积分和经验奖励,认真写原创书评 被采纳为精评可以获得大量金币、积分和经验奖励哦!