📄 logindialog.cpp
字号:
// LoginDialog.cpp : implementation file
//
#include "stdafx.h"
#include "MirX.h"
#include "LoginDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLoginDialog dialog
#define ServerCaption(str) (str.Left(str.Find("/",0)))
#define ServerName(str) (str.Mid(str.Find("/",0)+1))
CLoginDialog::CLoginDialog(CWnd* pParent /*=NULL*/)
: CDialog(CLoginDialog::IDD, pParent)
{
m_pGroupList=m_pServerList=NULL;
//{{AFX_DATA_INIT(CLoginDialog)
//}}AFX_DATA_INIT
}
void CLoginDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLoginDialog)
DDX_Control(pDX, IDC_CHAR_RIGHT, m_btnCharRight);
DDX_Control(pDX, IDC_CHAR_LEFT, m_btnCharLeft);
DDX_Control(pDX, IDC_SERVER, m_cbxServer);
DDX_Control(pDX, IDC_PWD, m_edtPassword);
DDX_Control(pDX, IDC_GROUP, m_cbxGroup);
DDX_Control(pDX, IDC_ACCOUNT, m_edtAccount);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLoginDialog, CDialog)
//{{AFX_MSG_MAP(CLoginDialog)
ON_CBN_SELCHANGE(IDC_GROUP, OnSelchangeGroup)
ON_CBN_SELCHANGE(IDC_SERVER, OnSelchangeServer)
ON_BN_CLICKED(IDC_CHAR_LEFT, OnCharLeft)
ON_BN_CLICKED(IDC_CHAR_RIGHT, OnCharRight)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLoginDialog message handlers
BOOL CLoginDialog::OnInitDialog()
{
CDialog::OnInitDialog();
char tmpBuf[64];
int i;
int iGroupCount;
SetTimer(815,333,NULL);
CString s;
iGroupCount=GetPrivateProfileInt("区","数",0,".\\Server.dll");
m_pGroupList=new CString[iGroupCount];
for(i=0;i<iGroupCount;i++)
{
s.Format("%d",i);
GetPrivateProfileString("区",s,"N/A",tmpBuf,64,".\\Server.dll");
m_pGroupList[i]=tmpBuf;
m_cbxGroup.AddString(m_pGroupList[i]);
}
m_cbxGroup.SetCurSel(GetPrivateProfileInt("上次","区",0,".\\Server.dll"));
OnSelchangeGroup();
m_cbxServer.SetCurSel(GetPrivateProfileInt("上次","服",0,".\\Server.dll"));
i=GetPrivateProfileInt("上次","角色",0,".\\Server.dll")&1;
if(i==0)
OnCharLeft();
else
OnCharRight();
GetPrivateProfileString("上次","帐号","",tmpBuf,64,".\\Server.dll");
m_edtAccount.SetWindowText(tmpBuf);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CLoginDialog::OnSelchangeGroup()
{
char tmpBuf[64];
int iCurSel;
int i;
int iServerCount;
CString strGroupName;
CString s;
iCurSel=m_cbxGroup.GetCurSel();
m_cbxServer.ResetContent();
m_cbxGroup.GetLBText(iCurSel,tmpBuf);
strGroupName=tmpBuf;
iServerCount=GetPrivateProfileInt(strGroupName,"数",0,".\\Server.dll");
if(m_pServerList!=NULL)delete []m_pServerList;
m_pServerList=new CString[iServerCount];
for(i=0;i<iServerCount;i++)
{
s.Format("%d",i);
GetPrivateProfileString(strGroupName,s,"",tmpBuf,64,".\\Server.dll");
m_pServerList[i]=tmpBuf;
m_cbxServer.AddString(ServerCaption(m_pServerList[i]));
}
m_cbxServer.SetCurSel(0);
OnSelchangeServer();
GetPrivateProfileString(strGroupName,"IP","",tmpBuf,64,".\\Server.dll");
m_ServerIP=tmpBuf;
}
void CLoginDialog::OnSelchangeServer()
{
m_ServerName=ServerName(m_pServerList[m_cbxServer.GetCurSel()]);
}
void CLoginDialog::OnOK()
{
m_edtAccount.GetWindowText(m_Account);
m_edtPassword.GetWindowText(m_Password);
CString s;
WritePrivateProfileString("上次","帐号",m_Account,".\\Server.dll");
s.Format("%d",m_cbxGroup.GetCurSel());
WritePrivateProfileString("上次","区",s,".\\Server.dll");
s.Format("%d",m_cbxServer.GetCurSel());
WritePrivateProfileString("上次","服",s,".\\Server.dll");
s.Format("%d",m_Character);
WritePrivateProfileString("上次","角色",s,".\\Server.dll");
CDialog::OnOK();
}
void CLoginDialog::OnCharLeft()
{
m_Character=0;
m_btnCharLeft.SetCheck(1);
m_btnCharRight.SetCheck(0);
}
void CLoginDialog::OnCharRight()
{
m_Character=1;
m_btnCharLeft.SetCheck(0);
m_btnCharRight.SetCheck(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -