ConnectServerDlg.cpp
资源名称:QQ示例源码.rar [点击查看]
上传用户:power_led
上传日期:2013-04-11
资源大小:373k
文件大小:2k
源码类别:
ICQ/即时通讯
开发平台:
Visual C++
- // ConnectServerDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ChatClient.h"
- #include "ConnectServerDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CConnectServerDlg dialog
- CConnectServerDlg::CConnectServerDlg(CString strName,CString strServerIp,int iServerPort,CWnd* pParent /*=NULL*/)
- : CDialog(CConnectServerDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CConnectServerDlg)
- m_strServerIp = strServerIp;
- m_iServerPort = iServerPort;
- m_bServerSpecial = FALSE;
- m_strUserName = _T(strName);
- //}}AFX_DATA_INIT
- }
- void CConnectServerDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CConnectServerDlg)
- DDX_Text(pDX, IDC_SERVERIP, m_strServerIp);
- DDX_Text(pDX, IDC_SERVERPORT, m_iServerPort);
- DDV_MinMaxInt(pDX, m_iServerPort, 0, 65536);
- DDX_Check(pDX, IDC_SERVERSPECIAL, m_bServerSpecial);
- DDX_Text(pDX, IDC_CLIENTUSERNAME, m_strUserName);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CConnectServerDlg, CDialog)
- //{{AFX_MSG_MAP(CConnectServerDlg)
- ON_BN_CLICKED(IDC_SERVERSPECIAL, OnServerspecial)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CConnectServerDlg message handlers
- extern CChatClientApp theApp;
- void CConnectServerDlg::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData();
- if(m_strUserName.GetLength())
- {
- theApp.IniFile.SetVarStr("USERNAME","DEFUALTNAME",m_strUserName,0);
- theApp.IniFile.SetVarStr("SERVERIP","DEFUALTSERVERIP",m_strServerIp,0);
- theApp.IniFile.SetVarInt("SERVERPORT","DEFAULTSERVERPORT",m_iServerPort,0);
- CDialog::OnOK();
- }
- }
- BOOL CConnectServerDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- GetClientRect(&rect);
- TempRect = rect;
- rect.bottom /= 2;
- rect.bottom += 20;
- ClientToScreen(&rect);
- MoveWindow(&rect);
- CenterWindow(GetDesktopWindow());
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CConnectServerDlg::OnServerspecial()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- if(!m_bServerSpecial)
- {
- MoveWindow(rect);
- }
- else
- {
- MoveWindow(TempRect);
- }
- CenterWindow();
- return;
- }