CChufangSettingWnd.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "../pch/pch.h"
  2. #include "CChufangSettingWnd.h"
  3. void CChufangSettingWnd::HandleLogin()
  4. {
  5. //判断账号密码是否正确
  6. std::wstring account, password;
  7. CEditUI* pAccountEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
  8. if (pAccountEdit)
  9. {
  10. account = pAccountEdit->GetText().GetData();
  11. }
  12. CEditUI* pPasswordEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("pwdedit")));
  13. if (pPasswordEdit)
  14. {
  15. password = pPasswordEdit->GetText().GetData();
  16. }
  17. LOG_INFO("account:" << account.c_str() << ", password:" << password.c_str());
  18. string s_account = CLewaimaiString::UnicodeToUTF8(account);
  19. string s_password = CLewaimaiString::UnicodeToUTF8(password);
  20. CZhipuziHttpClient::Init(s_account, s_password);
  21. std::string errmsg;
  22. bool res = CZhipuziHttpClient::Login(errmsg);
  23. if (res)
  24. {
  25. CMainWnd* pFrame = new CMainWnd();
  26. if (pFrame == NULL)
  27. {
  28. return;
  29. }
  30. pFrame->SetIcon(IDI_ICON_DUILIB);
  31. pFrame->Create(NULL, _T("游戏中心"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 1024, 738);
  32. pFrame->CenterWindow();
  33. ::ShowWindow(*pFrame, SW_SHOWMAXIMIZED);
  34. Close();
  35. }
  36. else
  37. {
  38. //登录失败了
  39. CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
  40. pLoginResultLabel->SetText(std::wstring(_T("登录失败:") + CLewaimaiString::UTF8ToUnicode(errmsg)).c_str());
  41. pLoginResultLabel->SetVisible(true);
  42. }
  43. }