Added a timer to periodically check for updates.
This commit is contained in:
@@ -19,8 +19,10 @@
|
|||||||
#define IDS_ERR_MENU 117
|
#define IDS_ERR_MENU 117
|
||||||
#define IDS_ERR_POPUP 118
|
#define IDS_ERR_POPUP 118
|
||||||
#define IDS_ERR_HOOK 119
|
#define IDS_ERR_HOOK 119
|
||||||
#define IDS_ERR_MAXMIN 120
|
#define IDS_ERR_TIMER 120
|
||||||
#define IDS_RUNNING 121
|
#define IDS_ERR_MAXMIN 121
|
||||||
|
#define IDS_RUNNING 122
|
||||||
|
#define IDT_TIMER 123
|
||||||
#define IDR_MAINFRAME 128
|
#define IDR_MAINFRAME 128
|
||||||
#define IDD_MANUAL_EDITING 129
|
#define IDD_MANUAL_EDITING 129
|
||||||
#define IDC_EDIT_X 1000
|
#define IDC_EDIT_X 1000
|
||||||
@@ -48,6 +50,6 @@
|
|||||||
#define _APS_NEXT_RESOURCE_VALUE 130
|
#define _APS_NEXT_RESOURCE_VALUE 130
|
||||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1015
|
#define _APS_NEXT_CONTROL_VALUE 1015
|
||||||
#define _APS_NEXT_SYMED_VALUE 122
|
#define _APS_NEXT_SYMED_VALUE 124
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#define KEY_V 0x56
|
#define KEY_V 0x56
|
||||||
|
|
||||||
#define BUF_LEN 1024
|
#define BUF_LEN 1024
|
||||||
#define WM_WCW 0x8F00
|
#define WM_WCW (WM_APP + 0x0F00)
|
||||||
|
|
||||||
// Global variables:
|
// Global variables:
|
||||||
HINSTANCE hInst; // Instance
|
HINSTANCE hInst; // Instance
|
||||||
@@ -134,25 +134,6 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
|
|||||||
}
|
}
|
||||||
LocalFree(szArglist);
|
LocalFree(szArglist);
|
||||||
|
|
||||||
if (fCheckUpdates)
|
|
||||||
{
|
|
||||||
LOG_TO_FILE(L"%s(%d): Checking for updates is enabled, fCheckUpdates = %s", TEXT(__FUNCTION__), __LINE__, fCheckUpdates ? L"True" : L"False");
|
|
||||||
|
|
||||||
hUpdater = CreateThread(NULL, 0, &Updater, nullptr, 0, nullptr);
|
|
||||||
if (NULL == hUpdater)
|
|
||||||
{
|
|
||||||
DWORD dwLastError = GetLastError();
|
|
||||||
LOG_TO_FILE(L"%s(%d): Creating Updater thread failed! Error: %d", TEXT(__FUNCTION__), __LINE__, dwLastError);
|
|
||||||
MessageBoxW(NULL, L"Creating Updater thread failed!", szTitle, MB_OK | MB_ICONERROR);
|
|
||||||
CloseLogFile();
|
|
||||||
return dwLastError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_TO_FILE(L"%s(%d): Checking for updates is disabled, fCheckUpdates = %s", TEXT(__FUNCTION__), __LINE__, fCheckUpdates ? L"True" : L"False");
|
|
||||||
}
|
|
||||||
|
|
||||||
WNDCLASSEX wcex = { 0 };
|
WNDCLASSEX wcex = { 0 };
|
||||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||||
wcex.lpfnWndProc = WndProc;
|
wcex.lpfnWndProc = WndProc;
|
||||||
@@ -254,6 +235,16 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
||||||
StringCchCopyW(nid.szTip, _countof(nid.szTip), szTitle);
|
StringCchCopyW(nid.szTip, _countof(nid.szTip), szTitle);
|
||||||
|
|
||||||
|
if (fCheckUpdates)
|
||||||
|
{
|
||||||
|
if (!SetTimer(hWnd, IDT_TIMER, 20000, NULL))
|
||||||
|
{
|
||||||
|
LOG_TO_FILE(L"%s(%d): Creating timer failed!", TEXT(__FUNCTION__), __LINE__);
|
||||||
|
ShowError(IDS_ERR_TIMER);
|
||||||
|
}
|
||||||
|
LOG_TO_FILE(L"%s(%d): Timer successfully created", TEXT(__FUNCTION__), __LINE__);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef _DEBUG
|
#ifndef _DEBUG
|
||||||
hMouseHook = SetWindowsHookExW(WH_MOUSE_LL, MouseHookProc, hInst, NULL);
|
hMouseHook = SetWindowsHookExW(WH_MOUSE_LL, MouseHookProc, hInst, NULL);
|
||||||
if (!hMouseHook)
|
if (!hMouseHook)
|
||||||
@@ -278,6 +269,36 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WM_TIMER:
|
||||||
|
{
|
||||||
|
if (fCheckUpdates)
|
||||||
|
{
|
||||||
|
LOG_TO_FILE(L"%s(%d): Checking for updates is enabled, fCheckUpdates = %s", TEXT(__FUNCTION__), __LINE__, fCheckUpdates ? L"True" : L"False");
|
||||||
|
|
||||||
|
Sleep(10000);
|
||||||
|
hUpdater = CreateThread(NULL, 0, &Updater, nullptr, 0, nullptr);
|
||||||
|
if (NULL == hUpdater)
|
||||||
|
{
|
||||||
|
DWORD dwLastError = GetLastError();
|
||||||
|
LOG_TO_FILE(L"%s(%d): Creating Updater thread failed! Error: %d", TEXT(__FUNCTION__), __LINE__, dwLastError);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!SetTimer(hWnd, IDT_TIMER, 86390000, NULL))
|
||||||
|
{
|
||||||
|
LOG_TO_FILE(L"%s(%d): Creating timer failed!", TEXT(__FUNCTION__), __LINE__);
|
||||||
|
ShowError(IDS_ERR_TIMER);
|
||||||
|
}
|
||||||
|
LOG_TO_FILE(L"%s(%d): Timer successfully created", TEXT(__FUNCTION__), __LINE__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_TO_FILE(L"%s(%d): Checking for updates is disabled, fCheckUpdates = %s", TEXT(__FUNCTION__), __LINE__, fCheckUpdates ? L"True" : L"False");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_WCW: // Popup menu handler
|
case WM_WCW: // Popup menu handler
|
||||||
{
|
{
|
||||||
if (IDI_TRAYICON == wParam && (WM_RBUTTONDOWN == lParam || WM_LBUTTONDOWN == lParam))
|
if (IDI_TRAYICON == wParam && (WM_RBUTTONDOWN == lParam || WM_LBUTTONDOWN == lParam))
|
||||||
@@ -342,11 +363,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default: return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||||
return DefWindowProcW(hWnd, message, wParam, lParam);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
@@ -450,6 +470,7 @@ BOOL CALLBACK DlgProc(HWND hDlg, UINT dlgmsg, WPARAM wParam, LPARAM lParam)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
|
{
|
||||||
switch (LOWORD(wParam))
|
switch (LOWORD(wParam))
|
||||||
{
|
{
|
||||||
case IDC_BUTTON_SET:
|
case IDC_BUTTON_SET:
|
||||||
@@ -478,8 +499,9 @@ BOOL CALLBACK DlgProc(HWND hDlg, UINT dlgmsg, WPARAM wParam, LPARAM lParam)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL IsWindowApprooved(HWND hFW)
|
BOOL IsWindowApprooved(HWND hFW)
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user