1 /* 2 * PROJECT: ReactOS CTF Monitor 3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) 4 * PURPOSE: Cicero Tipbar (Language Bar) loader window 5 * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com> 6 */ 7 8 #include "precomp.h" 9 #include "CLoaderWnd.h" 10 #include "CRegWatcher.h" 11 12 BOOL CLoaderWnd::s_bUninitedSystem = FALSE; 13 BOOL CLoaderWnd::s_bWndClassRegistered = FALSE; 14 15 BOOL CLoaderWnd::Init() 16 { 17 if (s_bWndClassRegistered) 18 return TRUE; // Already registered 19 20 // Register a window class 21 WNDCLASSEX wc; 22 ZeroMemory(&wc, sizeof(wc)); 23 wc.cbSize = sizeof(wc); 24 wc.style = CS_HREDRAW | CS_VREDRAW; 25 wc.hInstance = g_hInst; 26 wc.hCursor = LoadCursor(NULL, IDC_ARROW); 27 wc.lpfnWndProc = WindowProc; 28 wc.lpszClassName = TEXT("CiCTipBarClass"); 29 if (!::RegisterClassEx(&wc)) 30 return FALSE; 31 32 s_bWndClassRegistered = TRUE; // Remember 33 return TRUE; 34 } 35 36 HWND CLoaderWnd::CreateWnd() 37 { 38 m_hWnd = ::CreateWindowEx(0, TEXT("CiCTipBarClass"), NULL, WS_DISABLED, 39 0, 0, 0, 0, NULL, NULL, g_hInst, NULL); 40 return m_hWnd; 41 } 42 43 LRESULT CALLBACK 44 CLoaderWnd::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 45 { 46 switch (uMsg) 47 { 48 case WM_CREATE: 49 break; 50 51 case WM_DESTROY: 52 ::PostQuitMessage(0); 53 break; 54 55 case WM_QUERYENDSESSION: 56 // NOTE: We don't support Win95/98/Me 57 #ifdef SUPPORT_WIN9X 58 if (!(g_dwOsInfo & CIC_OSINFO_NT) && (!g_fWinLogon || (lParam & ENDSESSION_LOGOFF))) 59 { 60 ClosePopupTipbar(); 61 TF_UninitSystem(); 62 CLoaderWnd::s_bUninitedSystem = TRUE; 63 } 64 #endif 65 return TRUE; 66 67 case WM_ENDSESSION: 68 if (wParam) // The session is being ended? 69 { 70 if (!s_bUninitedSystem) 71 { 72 // Un-initialize now 73 UninitApp(); 74 TF_UninitSystem(); 75 s_bUninitedSystem = TRUE; 76 } 77 } 78 else if (s_bUninitedSystem) // Once un-initialized? 79 { 80 // Re-initialize 81 TF_InitSystem(); 82 if (!g_bOnWow64) 83 GetPopupTipbar(hwnd, !!g_fWinLogon); 84 85 s_bUninitedSystem = FALSE; 86 } 87 break; 88 89 case WM_SYSCOLORCHANGE: 90 case WM_DISPLAYCHANGE: 91 if (!g_bOnWow64) // Is the system x86/x64 native? 92 CRegWatcher::StartSysColorChangeTimer(); 93 break; 94 95 default: 96 return DefWindowProc(hwnd, uMsg, wParam, lParam); 97 } 98 99 return 0; 100 } 101