深入浅出MFC第2版(PDF格式)-第45部分
按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
————未阅读完?加入书签已便下次继续阅读!
#0016 #define CObjectid 0xffff
#0017 #define CCmdTargetid 1
#0018 #define CWinThreadid 11
#0019 #define CWinAppid 111
#0020 #define CMyWinAppid 1111
#0021 #define CWndid 12
#0022 #define CFrameWndid 121
#0023 #define CMyFrameWndid 1211
#0024 #define CViewid 122
#0025 #define CMyViewid 1221
#0026 #define CDocumentid 13
#0027 #define CMyDocid 131
#0028
#0029 #include
#0030
#0031 /////////////////////////////////////////////////////////////////
#0032 // Window message map handling
#0033
181
…………………………………………………………Page 244……………………………………………………………
第篇 勿在浮砂築高台
#0034 struct AFX_MSGMAP_ENTRY; // declared below after CWnd
#0035
#0036 struct AFX_MSGMAP
#0037 {
#0038 AFX_MSGMAP* pBaseMessageMap;
#0039 AFX_MSGMAP_ENTRY* lpEntries;
#0040 };
#0041
#0042 #define DECLARE_MESSAGE_MAP()
#0043 static AFX_MSGMAP_ENTRY _messageEntries'';
#0044 static AFX_MSGMAP messageMap;
#0045 virtual AFX_MSGMAP* GetMessageMap() const;
#0046
#0047 #define BEGIN_MESSAGE_MAP(theClass; baseClass)
#0048 AFX_MSGMAP* theClass::GetMessageMap() const
#0049 { return &theClass::messageMap; }
#0050 AFX_MSGMAP theClass::messageMap =
#0051 { &(baseClass::messageMap);
#0052 (AFX_MSGMAP_ENTRY*) &(theClass::_messageEntries) };
#0053 AFX_MSGMAP_ENTRY theClass::_messageEntries'' =
#0054 {
#0055
#0056 #define END_MESSAGE_MAP()
#0057 { 0; 0; 0; 0; AfxSig_end; (AFX_PMSG)0 }
#0058 };
#0059
#0060 // Message map signature values and macros in separate header
#0061 #include 〃afxmsg_。h〃
#0062
#0063 class CObject
#0064 {
#0065 public:
#0066 CObject::CObject() {
#0067 }
#0068 CObject::~CObject() {
#0069 }
#0070 };
#0071
#0072 class CCmdTarget : public CObject
#0073 {
#0074 public:
#0075 CCmdTarget::CCmdTarget() {
#0076 }
#0077 CCmdTarget::~CCmdTarget() {
#0078 }
#0079 DECLARE_MESSAGE_MAP() // base class no {{ }} macros
182
…………………………………………………………Page 245……………………………………………………………
第3章 MFC 六大關鍵技術之模擬
#0080 };
#0081
#0082 typedef void (CCmdTarget::*AFX_PMSG)(void);
#0083
#0084 struct AFX_MSGMAP_ENTRY // MFC 4。0
#0085 {
#0086 UINT nMessage; // windows message
#0087 UINT nCode; // control code or WM_NOTIFY code
#0088 UINT nID; // control ID (or 0 for windows messages)
#0089 UINT nLastID; // used for entries specifying a range of control id's
#0090 UINT nSig; // signature type (action) or pointer to message #
#0091 AFX_PMSG pfn; // routine to call (or special value)
#0092 };
#0093
#0094 class CWinThread : public CCmdTarget
#0095 {
#0096 public:
#0097 CWinThread::CWinThread() {
#0098 }
#0099 CWinThread::~CWinThread() {
#0100 }
#0101
#0102 virtual BOOL InitInstance() {
#0103 cout