Advertisement
Guest User

source

a guest
Mar 24th, 2021
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.38 KB | None | 0 0
  1. #include "init_splash_ui.h"
  2.  
  3. ECLInitSplashUI::ECLInitSplashUI()
  4. {
  5.     m_InitLoadWindow = NULL;
  6. }
  7.  
  8. ECLInitSplashUI::~ECLInitSplashUI()
  9. {
  10.     m_InitLoadWindow = NULL;
  11. }
  12.  
  13. void ECLInitSplashUI::SetEvent(CSDKDemoAppEvent* pAppEvent)
  14. {
  15.     m_pAppEvent = pAppEvent;
  16. }
  17.  
  18. void ECLInitSplashUI::InitWindow()
  19. {
  20.     m_InitLoadWindow = static_cast<CControlUI*>(m_PaintManager.FindControl(_T("window")));
  21.  
  22.     RECT rc = { 0 };
  23.     if (!::GetClientRect(m_hWnd, &rc)) return;
  24.     rc.right = rc.left + 1380;
  25.     rc.bottom = rc.top + 750;
  26.     if (!::AdjustWindowRectEx(&rc, GetWindowStyle(m_hWnd), (!(GetWindowStyle(m_hWnd) & WS_CHILD) && (::GetMenu(m_hWnd) != NULL)), GetWindowExStyle(m_hWnd))) return;
  27.     int ScreenX = GetSystemMetrics(SM_CXSCREEN);
  28.     int ScreenY = GetSystemMetrics(SM_CYSCREEN);
  29.  
  30.     ::SetWindowPos(m_hWnd, NULL, (ScreenX - (rc.right - rc.left)) / 2,
  31.         (ScreenY - (rc.bottom - rc.top)) / 2, rc.right - rc.left, rc.bottom - rc.top, SWP_NOZORDER | SWP_SHOWWINDOW);
  32.  
  33.     m_InitLoadWindow->SetVisible(true);
  34. }
  35.  
  36. void ECLInitSplashUI::Notify(TNotifyUI& msg)
  37. {
  38.  
  39. }
  40.  
  41. LRESULT ECLInitSplashUI::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
  42. {
  43.     LRESULT lRes = 0;
  44.     BOOL bHandled = TRUE;
  45.  
  46.     if (uMsg == WM_CREATE)
  47.     {
  48.         m_PaintManager.Init(m_hWnd);
  49.  
  50.         CDialogBuilder builder;
  51.         STRINGorID xml(GetSkinRes());
  52.         CControlUI* pRoot = builder.Create(xml, _T("xml"), 0, &m_PaintManager);
  53.         ASSERT(pRoot && "Failed to parse XML");
  54.  
  55.         m_PaintManager.AttachDialog(pRoot);
  56.         m_PaintManager.AddNotifier(this);
  57.         InitWindow();
  58.  
  59.         return lRes;
  60.     }
  61.     else if (uMsg == WM_CLOSE)
  62.     {
  63.         OnClose(uMsg, wParam, lParam, bHandled);
  64.     }
  65.     else if (uMsg == WM_DESTROY)
  66.     {
  67.         OnDestroy(uMsg, wParam, lParam, bHandled);
  68.     }
  69.  
  70.     if (m_PaintManager.MessageHandler(uMsg, wParam, lParam, lRes))
  71.     {
  72.         return lRes;
  73.     }
  74.  
  75.     return __super::HandleMessage(uMsg, wParam, lParam);
  76. }
  77.  
  78. LRESULT ECLInitSplashUI::OnClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
  79. {
  80.     if (m_pAppEvent)
  81.     {
  82.         m_pAppEvent->onQuitApp();
  83.     }
  84.     return 0;
  85. }
  86.  
  87. LRESULT ECLInitSplashUI::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
  88. {
  89.     // TODO Cleanup SDK
  90.     return 0;
  91. }
  92.  
  93. void ECLInitSplashUI::ShowErrorMessage(const wchar_t* error_message)
  94. {
  95.     if (error_message)
  96.         ::MessageBox(NULL, error_message, L"error", MB_OK);
  97. }
  98.  
  99. CSDKDemoAppEvent* ECLInitSplashUI::GetAppEvent()
  100. {
  101.     return m_pAppEvent;
  102. }
  103.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement