Changed C-style type conversion to C++ style.

This commit is contained in:
2023-12-11 21:25:59 +03:00
parent 5b205ad2e4
commit 6ba949de4b
4 changed files with 23 additions and 23 deletions

View File

@@ -39,8 +39,6 @@ public:
private: private:
SYSTEMTIME lt; SYSTEMTIME lt;
CRITICAL_SECTION cs; CRITICAL_SECTION cs;
HANDLE hLoggerThread = NULL;
HANDLE hLoggerEvent = NULL;
wchar_t logTimeBuffer[28]{ 0 }; wchar_t logTimeBuffer[28]{ 0 };
wchar_t logBuffer[MAX_LOGBUFFER_LENGTH]{ 0 }; wchar_t logBuffer[MAX_LOGBUFFER_LENGTH]{ 0 };
std::wofstream fsLogFile; std::wofstream fsLogFile;

View File

@@ -46,7 +46,7 @@ void FillVersionStructure(Version& ver, const std::wstring& str);
std::vector<std::wstring> Split(const std::wstring& s, wchar_t delim); std::vector<std::wstring> Split(const std::wstring& s, wchar_t delim);
std::wstring ConvertUtf8ToWide(const std::string& str); std::wstring ConvertUtf8ToWide(const std::string& str);
UINT WINAPI Updater(LPVOID) UINT WINAPI Updater(void*)
{ {
logger.Out(L"Entering the %s() function", TEXT(__FUNCTION__)); logger.Out(L"Entering the %s() function", TEXT(__FUNCTION__));
logger.Out(L"[UPDT] Sleeping %d seconds", T0); logger.Out(L"[UPDT] Sleeping %d seconds", T0);

View File

@@ -65,10 +65,10 @@ LPVOID szWinTitleBuffer = nullptr;
VOID HandlingTrayIcon(); VOID HandlingTrayIcon();
VOID ShowError(UINT); VOID ShowError(UINT);
BOOL IsWindowApprooved(HWND); BOOL IsWindowApprooved(HWND);
BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK KeyboardHookProc(int, WPARAM, LPARAM); LRESULT CALLBACK KeyboardHookProc(int, WPARAM, LPARAM);
LRESULT CALLBACK MouseHookProc(int, WPARAM, LPARAM); LRESULT CALLBACK MouseHookProc(int, WPARAM, LPARAM);
INT_PTR CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
VOID MoveWindowToMonitorCenter(HWND hwnd, BOOL bWorkArea, BOOL bResize) VOID MoveWindowToMonitorCenter(HWND hwnd, BOOL bWorkArea, BOOL bResize)
@@ -207,12 +207,12 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
Shell_NotifyIconW(NIM_DELETE, &nid); Shell_NotifyIconW(NIM_DELETE, &nid);
DestroyIcon(hIcon); DestroyIcon(hIcon);
logger.Out(L"Exit from the %s() function, msg.wParam = 0x%08X", TEXT(__FUNCTION__), (int)msg.wParam); logger.Out(L"Exit from the %s() function, msg.wParam = 0x%08X", TEXT(__FUNCTION__), static_cast<int>(msg.wParam));
HeapFree(hHeap, NULL, szWinTitleBuffer); HeapFree(hHeap, NULL, szWinTitleBuffer);
CloseHandle(hUpdater); CloseHandle(hUpdater);
return (int)msg.wParam; return static_cast<int>(msg.wParam);
} }
LRESULT CALLBACK WndProc(HWND hMainWnd, UINT message, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK WndProc(HWND hMainWnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -296,7 +296,7 @@ LRESULT CALLBACK WndProc(HWND hMainWnd, UINT message, WPARAM wParam, LPARAM lPar
{ {
logger.Out(L"%s(%d): Checking for updates is enabled, fCheckUpdates = %s", TEXT(__FUNCTION__), __LINE__, fCheckUpdates ? L"True" : L"False"); logger.Out(L"%s(%d): Checking for updates is enabled, fCheckUpdates = %s", TEXT(__FUNCTION__), __LINE__, fCheckUpdates ? L"True" : L"False");
hUpdater = (HANDLE)_beginthreadex(NULL, 0, &Updater, NULL, 0, &dwUpdaterID); hUpdater = reinterpret_cast<HANDLE>(_beginthreadex(NULL, 0, &Updater, NULL, 0, &dwUpdaterID));
if (NULL == hUpdater) if (NULL == hUpdater)
{ {
DWORD dwLastError = GetLastError(); DWORD dwLastError = GetLastError();
@@ -351,7 +351,7 @@ LRESULT CALLBACK WndProc(HWND hMainWnd, UINT message, WPARAM wParam, LPARAM lPar
logger.Out(L"%s(%d): Pressed the 'About' menuitem", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): Pressed the 'About' menuitem", TEXT(__FUNCTION__), __LINE__);
bKPressed = TRUE; bKPressed = TRUE;
DialogBoxW(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hMainWnd, (DLGPROC)About); DialogBoxW(hInst, MAKEINTRESOURCEW(IDD_ABOUTBOX), hMainWnd, static_cast<DLGPROC>(About));
bKPressed = FALSE; bKPressed = FALSE;
} }
if (ID_POPUPMENU_EXIT == idMenu) if (ID_POPUPMENU_EXIT == idMenu)
@@ -368,7 +368,7 @@ LRESULT CALLBACK WndProc(HWND hMainWnd, UINT message, WPARAM wParam, LPARAM lPar
case WM_QUERYENDSESSION: case WM_QUERYENDSESSION:
{ {
logger.Out(L"%s(%d): Recieved the WM_QUERYENDSESSION message, lParam = 0x%08X", TEXT(__FUNCTION__), __LINE__, (long)lParam); logger.Out(L"%s(%d): Recieved the WM_QUERYENDSESSION message, lParam = 0x%08X", TEXT(__FUNCTION__), __LINE__, static_cast<LONG_PTR>(lParam));
PostQuitMessage(0); PostQuitMessage(0);
return TRUE; return TRUE;
@@ -406,7 +406,7 @@ LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{ {
LPKBDLLHOOKSTRUCT pkhs = { 0 }; LPKBDLLHOOKSTRUCT pkhs = { 0 };
pkhs = (LPKBDLLHOOKSTRUCT)lParam; pkhs = reinterpret_cast<LPKBDLLHOOKSTRUCT>(lParam);
if (WM_KEYUP == wParam) if (WM_KEYUP == wParam)
{ {
if (VK_LCONTROL == pkhs->vkCode) bLCTRL = FALSE; if (VK_LCONTROL == pkhs->vkCode) bLCTRL = FALSE;
@@ -450,7 +450,7 @@ LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{ {
logger.Out(L"%s(%d): Opening the 'Manual editing' dialog", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): Opening the 'Manual editing' dialog", TEXT(__FUNCTION__), __LINE__);
DialogBoxW(hInst, MAKEINTRESOURCE(IDD_MANUAL_EDITING), hFgWnd, (DLGPROC)DlgProc); DialogBoxW(hInst, MAKEINTRESOURCEW(IDD_MANUAL_EDITING), hFgWnd, static_cast<DLGPROC>(DlgProc));
SetForegroundWindow(hFgWnd); SetForegroundWindow(hFgWnd);
} }
else hFgWnd = NULL; else hFgWnd = NULL;
@@ -461,7 +461,7 @@ LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
return CallNextHookEx(NULL, nCode, wParam, lParam); return CallNextHookEx(NULL, nCode, wParam, lParam);
} }
BOOL CALLBACK DlgProc(HWND hDlg, UINT dlgmsg, WPARAM wParam, LPARAM lParam) INT_PTR CALLBACK DlgProc(HWND hDlg, UINT dlgmsg, WPARAM wParam, LPARAM lParam)
{ {
RECT rcFW = { 0 }; RECT rcFW = { 0 };
int x, y, w, h; int x, y, w, h;
@@ -507,7 +507,7 @@ BOOL CALLBACK DlgProc(HWND hDlg, UINT dlgmsg, WPARAM wParam, LPARAM lParam)
logger.Out(L"%s(%d): Window with handle 0x%08X was moved to %d, %d", TEXT(__FUNCTION__), __LINE__, hFgWnd, x, y); logger.Out(L"%s(%d): Window with handle 0x%08X was moved to %d, %d", TEXT(__FUNCTION__), __LINE__, hFgWnd, x, y);
return TRUE; return static_cast<INT_PTR>(TRUE);
break; break;
} }
case IDCANCEL: case IDCANCEL:
@@ -522,19 +522,19 @@ BOOL CALLBACK DlgProc(HWND hDlg, UINT dlgmsg, WPARAM wParam, LPARAM lParam)
break; break;
} }
} }
return FALSE; return static_cast<INT_PTR>(FALSE);
} }
BOOL IsWindowApprooved(HWND hFW) BOOL IsWindowApprooved(HWND hFW)
{ {
logger.Out(L"Entering the %s() function", TEXT(__FUNCTION__)); logger.Out(L"Entering the %s() function", TEXT(__FUNCTION__));
bool bApprooved = FALSE; BOOL bApprooved = FALSE;
if (hFW) if (hFW)
{ {
if (GetWindowTextW(hFW, (LPWSTR)szWinTitleBuffer, MAX_WINTITLE_BUFFER_LENGTH)) if (GetWindowTextW(hFW, static_cast<LPWSTR>(szWinTitleBuffer), MAX_WINTITLE_BUFFER_LENGTH))
{ {
logger.Out(L"%s(%d): Window handle: 0x%08X. Title: '%s'", TEXT(__FUNCTION__), __LINE__, hFW, (LPWSTR)szWinTitleBuffer); logger.Out(L"%s(%d): Window handle: 0x%08X. Title: '%s'", TEXT(__FUNCTION__), __LINE__, hFW, static_cast<LPWSTR>(szWinTitleBuffer));
} }
if (IsIconic(hFW)) if (IsIconic(hFW))
@@ -580,10 +580,10 @@ VOID HandlingTrayIcon()
if (fShowIcon) if (fShowIcon)
{ {
bool bResult1 = Shell_NotifyIconW(NIM_ADD, &nid); BOOL bResult1 = Shell_NotifyIconW(NIM_ADD, &nid);
logger.Out(L"%s(%d): Shell_NotifyIconW(NIM_ADD): %s", TEXT(__FUNCTION__), __LINE__, bResult1 ? L"True" : L"False"); logger.Out(L"%s(%d): Shell_NotifyIconW(NIM_ADD): %s", TEXT(__FUNCTION__), __LINE__, bResult1 ? L"True" : L"False");
bool bResult2 = Shell_NotifyIconW(NIM_SETVERSION, &nid); BOOL bResult2 = Shell_NotifyIconW(NIM_SETVERSION, &nid);
logger.Out(L"%s(%d): Shell_NotifyIconW(NIM_SETVERSION): %s", TEXT(__FUNCTION__), __LINE__, bResult2 ? L"True" : L"False"); logger.Out(L"%s(%d): Shell_NotifyIconW(NIM_SETVERSION): %s", TEXT(__FUNCTION__), __LINE__, bResult2 ? L"True" : L"False");
if (!bResult1 || !bResult2) if (!bResult1 || !bResult2)
@@ -648,7 +648,7 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
logger.Out(L"%s(%d): End of initializing the 'About' dialog", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): End of initializing the 'About' dialog", TEXT(__FUNCTION__), __LINE__);
return (INT_PTR)TRUE; return static_cast<INT_PTR>(TRUE);
break; break;
} }
@@ -663,7 +663,7 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
logger.Out(L"%s(%d): Pressed the donation link! :-)", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): Pressed the donation link! :-)", TEXT(__FUNCTION__), __LINE__);
return (INT_PTR)TRUE; return static_cast<INT_PTR>(TRUE);
} }
break; break;
} }
@@ -676,10 +676,10 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
logger.Out(L"%s(%d): Closing the 'About' dialog", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): Closing the 'About' dialog", TEXT(__FUNCTION__), __LINE__);
return (INT_PTR)TRUE; return static_cast<INT_PTR>(TRUE);
} }
break; break;
} }
} }
return (INT_PTR)FALSE; return static_cast<INT_PTR>(FALSE);
} }

View File

@@ -152,6 +152,7 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>comctl32.lib;wininet.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>comctl32.lib;wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(TargetName)-$(Platform)$(TargetExt)</OutputFile>
</Link> </Link>
<Manifest> <Manifest>
<AdditionalManifestFiles>%(AdditionalManifestFiles)</AdditionalManifestFiles> <AdditionalManifestFiles>%(AdditionalManifestFiles)</AdditionalManifestFiles>
@@ -177,6 +178,7 @@
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>false</GenerateDebugInformation> <GenerateDebugInformation>false</GenerateDebugInformation>
<AdditionalDependencies>comctl32.lib;wininet.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>comctl32.lib;wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(TargetName)-$(Platform)$(TargetExt)</OutputFile>
</Link> </Link>
<Manifest> <Manifest>
<AdditionalManifestFiles>%(AdditionalManifestFiles)</AdditionalManifestFiles> <AdditionalManifestFiles>%(AdditionalManifestFiles)</AdditionalManifestFiles>