PeeperClientDoc.cpp
上传用户:xztxsm
上传日期:2007-02-12
资源大小:150k
文件大小:2k
源码类别:

远程控制编程

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. #include "PeeperClient.h"
  3. #include "PeeperClientDoc.h"
  4. #include "PeeperFrm.h"
  5. #include "PeeperSetDlg.h"
  6. #include "../peeperlib.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. IMPLEMENT_DYNCREATE(CPeeperClientDoc, CDocument)
  13. BEGIN_MESSAGE_MAP(CPeeperClientDoc, CDocument)
  14. //{{AFX_MSG_MAP(CPeeperClientDoc)
  15. //}}AFX_MSG_MAP
  16. END_MESSAGE_MAP()
  17. CPeeperClientDoc::CPeeperClientDoc()
  18. {
  19. }
  20. CPeeperClientDoc::~CPeeperClientDoc()
  21. {
  22. }
  23. BOOL CPeeperClientDoc::OnNewDocument()
  24. {
  25. if (!CDocument::OnNewDocument())
  26. return FALSE;
  27. CPeeperSetDlg dlgSet;
  28. if(dlgSet.DoModal() != IDOK)
  29. {
  30. return FALSE;
  31. }
  32. m_strIP = dlgSet.m_strIP;
  33. m_uPort = dlgSet.m_uPort;
  34. m_nBits = dlgSet.m_nBits;
  35. m_nSpeed = dlgSet.m_nSpeed;
  36. return TRUE;
  37. }
  38. #define PEEPER_VERSION _T("PPV1.1")
  39. void CPeeperClientDoc::Serialize(CArchive& ar)
  40. {
  41. if (ar.IsStoring())
  42. {
  43. ar << PEEPER_SERVER_VER_15;
  44. ar << m_strIP;
  45. ar << m_uPort;
  46. ar << m_nBits;
  47. ar << m_nSpeed;
  48. }
  49. else
  50. {
  51. CString strVer;
  52. ar >> strVer;
  53. if((strVer.CompareNoCase(PEEPER_VERSION) == 0) ||
  54. (strVer.CompareNoCase(PEEPER_SERVER_VER_15) == 0))
  55. {
  56. ar >> m_strIP;
  57. ar >> m_uPort;
  58. ar >> m_nBits;
  59. ar >> m_nSpeed;
  60. }
  61. else
  62. {
  63. m_strIP = _T("127.0.0.1");
  64. m_uPort = PL_PEEPER_PORT;
  65. m_nBits = 4;
  66. m_nSpeed = 1000;
  67. }
  68. }
  69. }
  70. void CPeeperClientDoc::OnCloseDocument() 
  71. {
  72. CDocument::OnCloseDocument();
  73. ((CMainFrame *)AfxGetApp()->m_pMainWnd)->OnFileClose();
  74. }