3.4.2 具体实现(3)
- BOOL IfOutput;
- private:
- void MessageReceived(LPCSTR pText);
-
- // 属性
- public:
- CTelnetDoc* GetDocument();
- public:
-
- //重写父类的虚函数
- //{{AFX_VIRTUAL(CTelnetView)
- public:
- virtual void OnDraw(CDC *pDC); // overridden to draw this view
- virtual BOOL PreCreateWindow(CREATESTRUCT &cs);
- protected:
- virtual void OnInitialUpdate(); // called first time after construct
- virtual BOOL OnPreparePrinting(CPrintInfo *pInfo);
- virtual void OnBeginPrinting(CDC *pDC, CPrintInfo *pInfo);
- virtual void OnEndPrinting(CDC *pDC, CPrintInfo *pInfo);
- //}}AFX_VIRTUAL
-
- // Implementation
- public:
- int Find(CString str, char ch);
- virtual ~CTelnetView();
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext &dc) const;
- #endif
- protected:
- // Generated message map functions
- protected:
- //{{AFX_MSG(CTelnetView)
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg BOOL OnEraseBkgnd(CDC *pDC);
- afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg void OnFileNew();
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
(5) 在文件CTelnetView.cpp中,实现了文件CTelnetView.h中定义的各个方法。因为文件CTelnetView.cpp的代码比较多,所以接下来将按照步骤进行详细剖析。
① 使用include指令引入包含文件,并定义BEGIN_MESSAGE_MAP消息映射,具体实现代码如下:
- #include "stdafx.h"
- #include "CTelnet.h"
-
- #include "CTelnetDoc.h"
- #include "CTelnetView.h"
- #include "MainFrm.h"
- #include "ClientSocket.h"
- #include "Process.h"
-
- #include "HostDialog.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- extern CMultiDocTemplate *pDocTemplate;
-
- IMPLEMENT_DYNCREATE(CTelnetView, CScrollView)
- BEGIN_MESSAGE_MAP(CTelnetView, CScrollView)
- //{{AFX_MSG_MAP(CTelnetView)
- ON_WM_CHAR()
- ON_WM_SIZE()
- ON_WM_ERASEBKGND()
- ON_WM_KEYDOWN()
-
- //}}AFX_MSG_MAP
- // Standard printing commands
- ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
- ON_COMMAND(ID_FILE_NEW, OnFileNew)
-
- END_MESSAGE_MAP()