📄 logindlg.cpp
字号:
// LoginDlg.cpp : implementation file
//
#include "stdafx.h"
#include "client.h"
#include "LoginDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLoginDlg dialog
CLoginDlg::CLoginDlg(CWnd* pParent /*=NULL*/)
: CDialog(CLoginDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CLoginDlg)
m_strServerAddress = "127.0.0.1";
m_nServerPort = 5216;
m_strNickname = _T("");
//}}AFX_DATA_INIT
}
void CLoginDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLoginDlg)
DDX_Text(pDX, IDC_EDIT1, m_strServerAddress);
DDX_Text(pDX, IDC_EDIT2, m_nServerPort);
DDX_Text(pDX, IDC_EDIT3, m_strNickname);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLoginDlg, CDialog)
//{{AFX_MSG_MAP(CLoginDlg)
ON_WM_SHOWWINDOW()
ON_BN_CLICKED(IDC_DEFAULT, OnDefault)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLoginDlg message handlers
void CLoginDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
((CEdit *)GetDlgItem(IDC_EDIT3))->SetFocus();
}
void CLoginDlg::OnDefault()
{
// TODO: Add your control notification handler code here
m_strServerAddress = "10.13.64.4";
m_nServerPort = 5216;
UpdateData(false);
}
void CLoginDlg::OnCancel()
{
// TODO: Add extra cleanup here
CClientDlg *pClientDlg = (CClientDlg *)AfxGetMainWnd();
pClientDlg->EndDialog(IDCANCEL);
CDialog::OnCancel();
}
void CLoginDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData();
if(m_strNickname.GetLength() == 0)
MessageBox("昵称不能为空!");
else
{
CString strCaption;
CClientDlg *pClientDlg = (CClientDlg *)AfxGetMainWnd();
pClientDlg->m_strServerAddress = m_strServerAddress;
pClientDlg->m_nServerPort = m_nServerPort;
pClientDlg->m_strNickname = m_strNickname;
pClientDlg->GetWindowText(strCaption);
if(strCaption.Find(m_strNickname,0) == -1)
strCaption += " - " + m_strNickname;
pClientDlg->SetWindowText(strCaption);
CDialog::OnOK();
}
}
BOOL CLoginDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->message == WM_KEYDOWN)
{
if(pMsg->wParam==VK_RETURN)
{
CWnd *pWnd = this->GetDlgItem(IDC_EDIT3);
if(pMsg->hwnd == pWnd->m_hWnd)
OnOK();
}
}
return CDialog::PreTranslateMessage(pMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -