设为首页 加入收藏

TOP

3.4.2 具体实现(5)
2013-10-07 15:56:25 来源: 作者: 【 】 浏览:85
Tags:3.4.2 具体 实现

3.4.2  具体实现(5)

⑥ 定义函数OnInitialUpdate(),用于计算当前视图的初始化位置,具体代码如下:

  1. void CTelnetView::OnInitialUpdate()  
  2. {  
  3. CSize sizeTotal;  
  4.  
  5. // TODO: calculate the total size of this view  
  6. sizeTotal.cx = dtX * 80 + 3;  
  7. sizeTotal.cy = dtY * bufferLines + 3;  
  8. SetScrollSizes(MM_TEXT, sizeTotal);  
  9. //SetWindowPos(NULL, 0,0, sizeTotal.cx, sizeTotal.cy, SWP_NOMOVE);  
  10.  
  11. CScrollView::OnInitialUpdate();  
  12. }  

⑦ 定义函数OnPreparePrinting ()等,用于实现打印功能,具体代码如下:
  1. BOOL CTelnetView::OnPreparePrinting(CPrintInfo *pInfo)  
  2. {  
  3. // 默认打印准备  
  4. return DoPreparePrinting(pInfo);  
  5. }  
  6.  
  7. void CTelnetView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)  
  8. {  
  9. // TODO: add extra initialization before printing  
  10. }  
  11.  
  12. void CTelnetView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)  
  13. {  
  14. // TODO: add cleanup after printing  
  15. }  
  16.  
  17. // CTelnetView diagnostics  
  18.  
  19. #ifdef _DEBUG  
  20. void CTelnetView::AssertValid() const  
  21. {  
  22. CScrollView::AssertValid();  
  23. }  
  24.  
  25. void CTelnetView::Dump(CDumpContext &dc) const  
  26. {  
  27. CScrollView::Dump(dc);  
  28. }  

⑧ 定义函数GetDocument(),用于在非调试环境下运行此函数,具体代码如下:
  1. CTelnetDoc* CTelnetView::GetDocument()   
  2. {  
  3. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTelnetDoc)));  
  4. return (CTelnetDoc*)m_pDocument;  
  5. }  
  6. #endif //_DEBUG  

⑨ 定义函数ProcessMessage(),用于接受并分析数据,具体代码如下:
  1. //接收分析数据  
  2. void CTelnetView::ProcessMessage(CClientSocket *pSock)  
  3. {  
  4. if(!IsWindow(m_hWnd)) return;  
  5. if(!IsWindowVisible()) return;  
  6. //保存数据到m_bBuf  
  7. int nBytes = pSock->Receive(m_bBuf, ioBuffSize);  
  8. if(nBytes != SOCKET_ERROR)  
  9. {  
  10. int ndx = 0;  
  11. //每次读入一行数据  
  12. while(GetLine(m_bBuf, nBytes, ndx) != TRUE);  
  13. //进行协商  
  14. ProcessOptions();  
  15. MessageReceived(m_strNormalText);  
  16. }  
  17. m_strLine.Empty();  
  18. m_strResp.Empty();  
  19. }  

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇3.4.2 具体实现(4) 下一篇3.4.2 具体实现(6)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·工业机器人TCP校准中 (2025-12-25 05:19:17)
·opc 通讯协议与 TCP (2025-12-25 05:19:15)
·labview中tcp/ip通信 (2025-12-25 05:19:13)
·新书介绍《Python数 (2025-12-25 04:49:47)
·怎么利用 Python 进 (2025-12-25 04:49:45)