|
|
@@ -81,6 +81,11 @@ void CLoginWnd::Notify(TNotifyUI& msg)
|
|
|
{
|
|
|
if(msg.pSender->GetName() == _T("closebtn"))
|
|
|
{
|
|
|
+ if (m_is_login_ing)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
PostQuitMessage(0);
|
|
|
return;
|
|
|
}
|
|
|
@@ -300,6 +305,11 @@ LRESULT CLoginWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool&
|
|
|
{
|
|
|
if(uMsg == WM_KEYDOWN)
|
|
|
{
|
|
|
+ if (m_is_login_ing)
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
if(wParam == VK_RETURN)
|
|
|
{
|
|
|
CEditUI* pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
|
|
|
@@ -316,7 +326,8 @@ LRESULT CLoginWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool&
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- this->HandleLogin();
|
|
|
+ SetFocus(m_hWnd);
|
|
|
+ this->StartLogin();
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
@@ -341,7 +352,6 @@ LRESULT CLoginWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool&
|
|
|
else if (uMsg == WM_NEED_UPDATE)
|
|
|
{
|
|
|
//说明需要升级了
|
|
|
-
|
|
|
Update();
|
|
|
|
|
|
return true;
|
|
|
@@ -374,6 +384,8 @@ void CLoginWnd::StartLogin()
|
|
|
|
|
|
void CLoginWnd::HandleLogin()
|
|
|
{
|
|
|
+ m_is_login_ing = true;
|
|
|
+
|
|
|
CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
|
|
|
|
|
|
//真正登录前,先检测是否有需要更新
|
|
|
@@ -383,6 +395,8 @@ void CLoginWnd::HandleLogin()
|
|
|
bool ret = CLewaimaiHttpClient::Request("/version/getwindowsversion", params, response);
|
|
|
if (!ret)
|
|
|
{
|
|
|
+ m_is_login_ing = false;
|
|
|
+
|
|
|
pLoginResultLabel->SetText(std::wstring(_T("网络请求出错")).c_str());
|
|
|
pLoginResultLabel->SetVisible(true);
|
|
|
|
|
|
@@ -396,6 +410,8 @@ void CLoginWnd::HandleLogin()
|
|
|
|
|
|
if (document.HasParseError())
|
|
|
{
|
|
|
+ m_is_login_ing = false;
|
|
|
+
|
|
|
pLoginResultLabel->SetText(std::wstring(_T("服务器返回数据格式错误")).c_str());
|
|
|
pLoginResultLabel->SetVisible(true);
|
|
|
|
|
|
@@ -407,6 +423,8 @@ void CLoginWnd::HandleLogin()
|
|
|
{
|
|
|
if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
|
|
|
{
|
|
|
+ m_is_login_ing = false;
|
|
|
+
|
|
|
pLoginResultLabel->SetText(std::wstring(_T("服务器返回数据格式错误")).c_str());
|
|
|
pLoginResultLabel->SetVisible(true);
|
|
|
|
|
|
@@ -419,6 +437,8 @@ void CLoginWnd::HandleLogin()
|
|
|
int errcode = v_errcode.GetInt();
|
|
|
if (errcode != 0)
|
|
|
{
|
|
|
+ m_is_login_ing = false;
|
|
|
+
|
|
|
std::string errmsg = "response failed! message:" + string(document["errmsg"].GetString());
|
|
|
pLoginResultLabel->SetText(CLewaimaiString::UTF8ToUnicode(errmsg).c_str());
|
|
|
pLoginResultLabel->SetVisible(true);
|
|
|
@@ -435,11 +455,13 @@ void CLoginWnd::HandleLogin()
|
|
|
|
|
|
if (newest_version > CSystem::GetVersion())
|
|
|
{
|
|
|
+ m_is_login_ing = false;
|
|
|
+
|
|
|
//说明有新版本,要更新
|
|
|
PostMessage(WM_NEED_UPDATE);
|
|
|
return;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
//判断账号密码是否正确
|
|
|
std::wstring account, password;
|
|
|
@@ -468,6 +490,8 @@ void CLoginWnd::HandleLogin()
|
|
|
|
|
|
if (s_account.compare("") == 0)
|
|
|
{
|
|
|
+ m_is_login_ing = false;
|
|
|
+
|
|
|
pLoginResultLabel->SetText(std::wstring(_T("用户名不能为空")).c_str());
|
|
|
pLoginResultLabel->SetVisible(true);
|
|
|
|
|
|
@@ -478,6 +502,8 @@ void CLoginWnd::HandleLogin()
|
|
|
|
|
|
if (s_password.compare("") == 0)
|
|
|
{
|
|
|
+ m_is_login_ing = false;
|
|
|
+
|
|
|
pLoginResultLabel->SetText(std::wstring(_T("密码不能为空")).c_str());
|
|
|
pLoginResultLabel->SetVisible(true);
|
|
|
|
|
|
@@ -536,6 +562,8 @@ void CLoginWnd::HandleLogin()
|
|
|
|
|
|
PostMessage(WM_LOGIN_SUCCESS);
|
|
|
|
|
|
+ m_is_login_ing = false;
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
@@ -546,6 +574,8 @@ void CLoginWnd::HandleLogin()
|
|
|
pLoginResultLabel->SetText(std::wstring(_T("登录失败:") + CLewaimaiString::UTF8ToUnicode(errmsg)).c_str());
|
|
|
pLoginResultLabel->SetVisible(true);
|
|
|
|
|
|
+ m_is_login_ing = false;
|
|
|
+
|
|
|
PostMessage(WM_LOGIN_ERROR);
|
|
|
}
|
|
|
}
|
|
|
@@ -610,5 +640,6 @@ void CLoginWnd::ShowLoginAgainOut()
|
|
|
pMessagebox->Create(m_hWnd, _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
|
|
|
pMessagebox->SetIcon(IDI_ICON_DUILIB);
|
|
|
pMessagebox->CenterWindow();
|
|
|
+
|
|
|
UINT ret = pMessagebox->ShowModal();
|
|
|
}
|