ClientDlg.cpp

Upload User: lidebao1
Upload Date: 2013-05-01
Package Size: 2437k
Code Size: 2k
Category: Windows Develop
Development Platform: Visual C++
  1. // ClientDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "FiveChess.h"
  5. #include "ClientDlg.h"
  6. #include "FiveChessView.h"
  7. #include "MainFrm.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CClientDlg dialog
  15. CClientDlg::CClientDlg(CWnd* pParent /*=NULL*/)
  16. : CDialog(CClientDlg::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(CClientDlg)
  19. m_iPort = 5000;
  20. //}}AFX_DATA_INIT
  21. }
  22. void CClientDlg::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CDialog::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(CClientDlg)
  26. DDX_Control(pDX, IDC_IPADDRESS, m_address);
  27. DDX_Text(pDX, IDC_SERVERPORT, m_iPort);
  28. DDV_MinMaxInt(pDX, m_iPort, 1024, 100000);
  29. //}}AFX_DATA_MAP
  30. }
  31. BEGIN_MESSAGE_MAP(CClientDlg, CDialog)
  32. //{{AFX_MSG_MAP(CClientDlg)
  33. ON_BN_CLICKED(IDC_BUTTON, OnButton)
  34. //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CClientDlg message handlers
  38. void CClientDlg::OnButton() 
  39. {
  40. // TODO: Add your control notification handler code here
  41. m_iPort=GetDlgItemInt(IDC_SERVERPORT);
  42. CIPAddressCtrl *ip=(CIPAddressCtrl *)(GetDlgItem(IDC_IPADDRESS));
  43. ip->GetAddress(m_bIP[0],m_bIP[1],m_bIP[2],m_bIP[3]);
  44. this->EndDialog(2000);
  45. }
  46. BOOL CClientDlg::OnInitDialog() 
  47. {
  48. CDialog::OnInitDialog();
  49. // TODO: Add extra initialization here
  50. for(int i=0;i<4;i++)
  51. {
  52. m_bIP[i]=((CFiveChessView *)((CMainFrame*)::AfxGetMainWnd())->GetActiveView())->m_bIP[i];
  53. }
  54. CIPAddressCtrl *ip=(CIPAddressCtrl *)(GetDlgItem(IDC_IPADDRESS));
  55. ip->SetAddress(m_bIP[0],m_bIP[1],m_bIP[2],m_bIP[3]);
  56. return TRUE;  // return TRUE unless you set the focus to a control
  57.               // EXCEPTION: OCX Property Pages should return FALSE
  58. }