设为首页 加入收藏

TOP

3.4.2 具体实现(4)
2013-10-07 15:56:28 来源: 作者: 【 】 浏览:80
Tags:3.4.2 具体 实现

3.4.2  具体实现(4)

② 定义CTelnetView类的构造函数CTelnetView(),用于实现初始化工作。具体实现代码如下:

  1. CTelnetView::CTelnetView()  
  2. {  
  3. cTextColor = RGB(0, 200, 000);                  //设置字体颜色,此处是绿色  
  4. cBackgroundColor = RGB(000, 000, 000);          //设置背景颜色,此处是黑色  
  5. cSock = NULL;  
  6. bOptionsSent = FALSE;  
  7. TempCounter = 0;  
  8. cCursX = 0;  
  9. CurrentXX = 0;                                  //初始窗口的位置  
  10. CurrentYY = 0;  
  11.  
  12. IfOutput = false;  
  13. // OffsetNum = 0;  
  14. for(int x=0; x<80; x++)  
  15. {  
  16. for(int y=0; y<bufferLines; y++)  
  17. {  
  18. cText[x][y] = ' ';  
  19. }  
  20. }  
  21. }  

③ 定义CTelnetView类的构造函数CTelnetView(),如果cSock为空则释放。具体代码如下:
  1. CTelnetView::~CTelnetView()  
  2. {  
  3. if(cSock != NULL)  
  4. delete cSock;  
  5. cSock = NULL;  
  6. }  

④ 定义函数PreCreateWindow(),设定窗口的风格,CREATESTRUCT是窗口的风格数据结构。具体代码如下:
  1. BOOL CTelnetView::PreCreateWindow(CREATESTRUCT &cs)  
  2. {  
  3. return CScrollView::PreCreateWindow(cs);  
  4. }  

⑤ 定义函数OnDraw(CDC *pDC)以及DoDraw(CDC *pDC),实现窗口绘制,具体代码如下:
  1. void CTelnetView::OnDraw(CDC *pDC)  
  2. {  
  3. CTelnetDoc *pDoc = GetDocument();  
  4. ASSERT_VALID(pDoc);  
  5.  
  6. pDC->SelectObject(GetStockObject(ANSI_FIXED_FONT));  
  7.  
  8. DrawCursor(pDC, FALSE);  
  9. DoDraw(pDC);  
  10. DrawCursor(pDC, TRUE);  
  11. }  
  12.  
  13. void CTelnetView::DoDraw(CDC *pDC)  
  14. {  
  15. CString strLine;  
  16. BOOL bSkip = FALSE;  
  17. CRect clip;  
  18. pDC->GetClipBox(clip);  
  19. clip.top -dtY;  
  20.  
  21. pDC->SetTextColor(cTextColor);  
  22. // pDC->SetBkColor(cBackgroundColor);  
  23.  
  24. // CurrentXX = 0;  
  25. char text[2] = {0x00, 0x00};  
  26.  
  27. for(int y=0; y<bufferLines; y++)  
  28. {  
  29. //if(y*dtY >= clip.top)  
  30. //{  
  31. for(int x=0; x<80; x++)  
  32. {  
  33. text[0] = cText[x][y];  
  34. if(text[0] == 27)  
  35. bSkip = TRUE;  
  36. if(!bSkip)  
  37. strLine += text[0];  
  38. if(text[0]=='m' && bSkip)  
  39. bSkip = FALSE;  
  40. }  
  41. pDC->TextOut(0, y*dtY, strLine);  
  42. strLine.Empty();  
  43. //}  
  44. }  
  45. }  

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇1.5.3 CCS开发系统(2) 下一篇3.4.2 具体实现(5)

评论

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

·工业机器人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)