📄 login.cpp
字号:
// Login.cpp : implementation file
//
#include "stdafx.h"
#include "mychar.h"
#include "Login.h"
#include "taghead.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Login dialog
extern CMycharApp theApp;
Login::Login(CClientSocket *p_Socket, CWnd* pParent /*=NULL*/)
: CDialog(Login::IDD, pParent)
{
m_pSocket = p_Socket;
//{{AFX_DATA_INIT(Login)
m_strName = _T("");
m_strServer = _T("127.0.0.1");
//}}AFX_DATA_INIT
}
void Login::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Login)
DDX_Text(pDX, IDC_NAME, m_strName);
DDX_Text(pDX, IDC_SERVER, m_strServer);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Login, CDialog)
//{{AFX_MSG_MAP(Login)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Login message handlers
void Login::OnOK()
{
UpdateData();
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();
theApp.m_strName = m_strName;
m_pSocket->Send((char *)&head,sizeof(Header));
m_pSocket->Send(m_strName,m_strName.GetLength());
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -