按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
————未阅读完?加入书签已便下次继续阅读!
12 CWnd
1 CCmdTarget
CCmdTarget::OnCmdMsg()
1111 CMyWinApp
111 CWinApp
1 CCmdTarget
CWnd::DefWindowProc()
202
…………………………………………………………Page 265……………………………………………………………
第3章 MFC 六大關鍵技術之模擬
Frame8 范例程序
MFC。H
#0001 #define TRUE 1
#0002 #define FALSE 0
#0003
#0004 typedef char* LPSTR;
#0005 typedef const char* LPCSTR;
#0006
#0007 typedef unsigned long DWORD;
#0008 typedef int BOOL;
#0009 typedef unsigned char BYTE;
#0010 typedef unsigned short WORD;
#0011 typedef int INT;
#0012 typedef unsigned int UINT;
#0013 typedef long LONG;
#0014
#0015 typedef UINT WPARAM;
#0016 typedef LONG LPARAM;
#0017 typedef LONG LRESULT;
#0018 typedef int HWND;
#0019
#0020 #define WM_MAND 0x0111
#0021 #define WM_CREATE 0x0001
#0022 #define WM_PAINT 0x000F
#0023 #define WM_NOTIFY 0x004E
#0024
#0025 #define CObjectid 0xffff
#0026 #define CCmdTargetid 1
#0027 #define CWinThreadid 11
#0028 #define CWinAppid 111
#0029 #define CMyWinAppid 1111
#0030 #define CWndid 12
#0031 #define CFrameWndid 121
#0032 #define CMyFrameWndid 1211
#0033 #define CViewid 122
#0034 #define CMyViewid 1221
#0035 #define CDocumentid 13
#0036 #define CMyDocid 131
#0037
#0038 #include
#0039
#0040 /////////////////////////////////////////////////////////////////
203
…………………………………………………………Page 266……………………………………………………………
第篇 勿在浮砂築高台
#0041 // Window message map handling
#0042
#0043 struct AFX_MSGMAP_ENTRY; // declared below after CWnd
#0044
#0045 struct AFX_MSGMAP
#0046 {
#0047 AFX_MSGMAP* pBaseMessageMap;
#0048 AFX_MSGMAP_ENTRY* lpEntries;
#0049 };
#0050
#0051 #define DECLARE_MESSAGE_MAP()
#0052 static AFX_MSGMAP_ENTRY _messageEntries'';
#0053 static AFX_MSGMAP messageMap;
#0054 virtual AFX_MSGMAP* GetMessageMap() const;
#0055
#0056 #define BEGIN_MESSAGE_MAP(theClass; baseClass)
#0057 AFX_MSGMAP* theClass::GetMessageMap() const
#0058 { return &theClass::messageMap; }
#0059 AFX_MSGMAP theClass::messageMap =
#0060 { &(baseClass::messageMap);
#0061 (AFX_MSGMAP_ENTRY*) &(theClass::_messageEntries) };
#0062 AFX_MSGMAP_ENTRY theClass::_messageEntries'' =
#0063 {
#0064
#0065 #define END_MESSAGE_MAP()
#0066 { 0; 0; 0; 0; AfxSig_end; (AFX_PMSG)0 }
#0067 };
#0068
#0069 // Message map signature values and macros in separate header
#0070 #include 〃afxmsg_。h〃
#0071
#0072 class CObject
#0073 {
#0074 public:
#0075 CObject::CObject() {
#0076 }
#0077 CObject::~CObject() {
#0078 }
#0079 };
#0080
#0081 class CCmdTarget : public CObject
#0082 {
#0083 public:
#0084 CCmdTarget::CCmdTarget() {
#0085 }
#0086 CCmdTarget::~CCmdTarget() {
204
…………………………………………………………Page 267……………………………………………………………
第3章 MFC 六大關鍵技術之模擬
#0087 }
#0088
#0089 virtual BOOL OnCmdMsg(UINT nID; int nCode);
#0090
#0091 DECLARE_MESSAGE_MAP() // base class no {{ }} macros
#0092 };
#0093
#0094 typedef void (CCmdTarget::*AFX_PMSG)(void);
#0095
#0096 struct AFX_MSGMAP_ENTRY // MFC 4。0
#0097 {
#0098 UINT nMessage; // windows message
#0099 UINT nCode; // control code or WM_NOTIFY code
#0100 UINT nID; // control ID (or 0 for windows messages)
#0101 UINT nLastID; // used for entries specifying a range of control id's
#0102 UINT nSig; // signature type (action) or pointer to message #
#0103 AFX_PMSG pfn; // routine to call (or special value)
#0104 };
#0105
#0106 class CWinThread : public CCmdTarget
#0107 {
#0108 public:
#0109 CWinThread::CWinThread() {
#0110