📄 regdlg.cpp
字号:
// RegDlg.cpp : implementation file
//
#include "stdafx.h"
#include "StockRefer.h"
#include "RegDlg.h"
#include "HttpDown.h"
#include "CmdWaitDlg.h"
#include "SerialNum.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRegDlg dialog
CRegDlg::CRegDlg(CWnd* pParent /*=NULL*/)
: CDialog(CRegDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRegDlg)
//}}AFX_DATA_INIT
}
void CRegDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRegDlg)
DDX_Control(pDX, IDC_SOFTID_COL3, m_col3);
DDX_Control(pDX, IDC_SOFTID_COL2, m_col2);
DDX_Control(pDX, IDC_SOFTID_COL1, m_col1);
DDX_Control(pDX, IDC_SOFTID_COL0, m_col0);
DDX_Control(pDX, IDOK, m_ok);
DDX_Control(pDX, IDC_NAME, m_name);
DDX_Control(pDX, IDC_EMAIL, m_email);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRegDlg, CDialog)
//{{AFX_MSG_MAP(CRegDlg)
ON_EN_CHANGE(IDC_SOFTID_COL0, OnChangeSoftidCol0)
ON_EN_CHANGE(IDC_SOFTID_COL1, OnChangeSoftidCol1)
ON_EN_CHANGE(IDC_SOFTID_COL2, OnChangeSoftidCol2)
ON_EN_CHANGE(IDC_SOFTID_COL3, OnChangeSoftidCol3)
ON_BN_CLICKED(IDC_BUTTON_GET, OnButtonGet)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRegDlg message handlers
void CRegDlg::OnChangeSoftidCol0()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
CString m_strVal;
m_col0.GetWindowText(m_strVal);
if(m_strVal.GetLength() >= 5)
{
m_col1.SetSel(0,-1);
m_col1.SetFocus();
}
}
void CRegDlg::OnChangeSoftidCol1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
CString m_strVal;
m_col1.GetWindowText(m_strVal);
if(m_strVal.GetLength() >= 5)
{
m_col2.SetSel(0,-1);
m_col2.SetFocus();
}
}
void CRegDlg::OnChangeSoftidCol2()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
CString m_strVal;
m_col2.GetWindowText(m_strVal);
if(m_strVal.GetLength() >= 5)
{
m_col3.SetSel(0,-1);
m_col3.SetFocus();
}
}
void CRegDlg::OnChangeSoftidCol3()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
CString m_strVal;
m_col3.GetWindowText(m_strVal);
if(m_strVal.GetLength() >= 5)
GetDlgItem(IDOK)->SetFocus();
}
BOOL CRegDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_col0.SetLimitText(5);
m_col1.SetLimitText(5);
m_col2.SetLimitText(5);
m_col3.SetLimitText(5);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CRegDlg::OnOK()
{
// TODO: Add extra validation here
CHttpDown news;
CSerialNum num;
CString url,sname,rtn,semail,ssoftid,tip;
long sid;
int m_rtn = 0;
CStockReferApp *app = (CStockReferApp *)AfxGetApp();
m_name.GetWindowText(sname);
sname.Replace(_T("&"),NULL);
sid = num.GetDiskSerialNo();
m_email.GetWindowText(semail);
semail.Replace(_T("&"),NULL);
CString strCol0,strCol1,strCol2,strCol3;
m_col0.GetWindowText(strCol0);
m_col1.GetWindowText(strCol1);
m_col2.GetWindowText(strCol2);
m_col3.GetWindowText(strCol3);
if(strCol0.IsEmpty() && strCol1.IsEmpty() &&
strCol2.IsEmpty() && strCol3.IsEmpty())
ssoftid = _T("-1");
else
ssoftid.Format(_T("%s-%s-%s-%s"),strCol0,strCol1,strCol2,strCol3);
ssoftid.Replace(_T("&"),NULL);
url.Format(REG_URL,sname,semail,ssoftid,sid);
CWaitDialog waitdlg;
waitdlg.Show();
rtn = news.GetHttpFileGet(url);
waitdlg.Close();
if(rtn.IsEmpty())
{
tip = _T("连接到服务器失败,请稍候再试。");
AfxMessageBox(tip);
}
else if(rtn == _T("-1\n"))
{
tip = _T("服务器处理发生错误,请确定您所填的内容是正确无误的。");
AfxMessageBox(tip);
}
else if(app->m_strSer == rtn)
{
num.SetReg(rtn);
HAS_REG = TRUE;
m_rtn = 1;
CString strSuccess;
strSuccess.LoadString(AFX_IDS_APP_TITLE);
strSuccess = _T("欢迎您成为 ") + strSuccess + _T(" 正式版的合法用户。\n今后在使用中如有问题,请与我们联系。");
AfxMessageBox(strSuccess);
}
else
AfxMessageBox(_T("连接到服务器失败,请稍候再试。"));
if(m_rtn != 0)
CDialog::OnOK();
}
void CRegDlg::OnButtonGet()
{
// TODO: Add your control notification handler code here
AfxGetMainWnd()->SendMessage(WM_COMMAND,ID_HELP_MAILTO,0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -