ConnectServerDlg.cpp
上传用户:power_led
上传日期:2013-04-11
资源大小:373k
文件大小:2k
源码类别:

ICQ/即时通讯

开发平台:

Visual C++

  1. // ConnectServerDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ChatClient.h"
  5. #include "ConnectServerDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CConnectServerDlg dialog
  13. CConnectServerDlg::CConnectServerDlg(CString strName,CString strServerIp,int iServerPort,CWnd* pParent /*=NULL*/)
  14. : CDialog(CConnectServerDlg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CConnectServerDlg)
  17. m_strServerIp = strServerIp;
  18. m_iServerPort = iServerPort;
  19. m_bServerSpecial = FALSE;
  20. m_strUserName = _T(strName);
  21. //}}AFX_DATA_INIT
  22. }
  23. void CConnectServerDlg::DoDataExchange(CDataExchange* pDX)
  24. {
  25. CDialog::DoDataExchange(pDX);
  26. //{{AFX_DATA_MAP(CConnectServerDlg)
  27. DDX_Text(pDX, IDC_SERVERIP, m_strServerIp);
  28. DDX_Text(pDX, IDC_SERVERPORT, m_iServerPort);
  29. DDV_MinMaxInt(pDX, m_iServerPort, 0, 65536);
  30. DDX_Check(pDX, IDC_SERVERSPECIAL, m_bServerSpecial);
  31. DDX_Text(pDX, IDC_CLIENTUSERNAME, m_strUserName);
  32. //}}AFX_DATA_MAP
  33. }
  34. BEGIN_MESSAGE_MAP(CConnectServerDlg, CDialog)
  35. //{{AFX_MSG_MAP(CConnectServerDlg)
  36. ON_BN_CLICKED(IDC_SERVERSPECIAL, OnServerspecial)
  37. //}}AFX_MSG_MAP
  38. END_MESSAGE_MAP()
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CConnectServerDlg message handlers
  41. extern CChatClientApp theApp;
  42. void CConnectServerDlg::OnOK() 
  43. {
  44. // TODO: Add extra validation here
  45. UpdateData();
  46. if(m_strUserName.GetLength())
  47. {
  48. theApp.IniFile.SetVarStr("USERNAME","DEFUALTNAME",m_strUserName,0);
  49. theApp.IniFile.SetVarStr("SERVERIP","DEFUALTSERVERIP",m_strServerIp,0);
  50. theApp.IniFile.SetVarInt("SERVERPORT","DEFAULTSERVERPORT",m_iServerPort,0);
  51. CDialog::OnOK();
  52. }
  53. }
  54. BOOL CConnectServerDlg::OnInitDialog() 
  55. {
  56. CDialog::OnInitDialog();
  57. // TODO: Add extra initialization here
  58. GetClientRect(&rect);
  59. TempRect = rect;
  60. rect.bottom /= 2;
  61. rect.bottom += 20;
  62. ClientToScreen(&rect);
  63. MoveWindow(&rect);
  64. CenterWindow(GetDesktopWindow());
  65. return TRUE;  // return TRUE unless you set the focus to a control
  66.               // EXCEPTION: OCX Property Pages should return FALSE
  67. }
  68. void CConnectServerDlg::OnServerspecial() 
  69. {
  70. // TODO: Add your control notification handler code here
  71. UpdateData();
  72. if(!m_bServerSpecial)
  73. {
  74. MoveWindow(rect);
  75. }
  76. else
  77. {
  78. MoveWindow(TempRect);
  79. }
  80. CenterWindow();
  81. return;
  82. }