📄 logindlg.cpp
字号:
// LoginDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MyChat.h"
#include "LoginDlg.h"
#include "ClientSocket.h"
#include "tagHeader.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CMyChatApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CLoginDlg dialog
CLoginDlg::CLoginDlg(CClientSocket *p_Socket, CWnd* pParent /*=NULL*/)
: CDialog(CLoginDlg::IDD, pParent)
{
ASSERT(p_Socket);
m_pSocket = p_Socket;
//{{AFX_DATA_INIT(CLoginDlg)
m_strName = _T("杨柳");
m_strServer = _T("10.4.11.7");
//}}AFX_DATA_INIT
}
void CLoginDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLoginDlg)
DDX_Text(pDX, IDC_EDIT_NAME, m_strName);
DDX_Text(pDX, IDC_EDIT_SERVER, m_strServer);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLoginDlg, CDialog)
//{{AFX_MSG_MAP(CLoginDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLoginDlg message handlers
void CLoginDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData();
// m_pSocket->m_strName = this->m_strName;
if(!m_pSocket->Create())
{
AfxMessageBox("网络创建错误!!!");
m_pSocket->Close();
return;
}
if(!m_pSocket->Connect(m_strServer,9999))
{
AfxMessageBox("连接服务器失败!!!");
m_pSocket->Close();
return;
}
Header head;
head.type = LOGIN_IO;
head.len = m_strName.GetLength();
m_pSocket->Send((char *)&head,sizeof(Header));
m_pSocket->Send(m_strName,m_strName.GetLength());
theApp.m_strName = m_strName;
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -