Skip to content

Commit 2f671f9

Browse files
committed
Set focus on service start/stop button only when window is visible
Fixes #34
1 parent 759c0c3 commit 2f671f9

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

CHANGES

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
Revision history for GLPI Agent Monitor
22

3+
Future version
4+
5+
* Fixed a bug where pressing the Space or Enter/Return keys during a restart
6+
of the Agent service can cause the Start/Stop service button to be pressed
7+
even when the Monitor window is not visible, triggering a UAC prompt if the
8+
user is not an administrator.
9+
10+
311
1.4.0
412

513
* Dutch translation added

GLPI-AgentMonitor.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* ---------------------------------------------------------------------------
33
* GLPI-AgentMonitor.cpp
4-
* Copyright (C) 2023, 2024 Leonardo Bernardes (redddcyclone)
4+
* Copyright (C) 2023, 2025 Leonardo Bernardes (redddcyclone)
55
* ---------------------------------------------------------------------------
66
*
77
* LICENSE
@@ -441,7 +441,9 @@ VOID CALLBACK UpdateServiceStatus(HWND hWnd, UINT message, UINT idTimer, DWORD d
441441

442442
HWND hWndSvcButton = GetDlgItem(hWnd, IDC_BTN_STARTSTOPSVC);
443443
EnableWindow(hWndSvcButton, bEnableButton);
444-
SetFocus(hWndSvcButton);
444+
if (IsWindowVisible(hWnd)) {
445+
SetFocus(hWndSvcButton);
446+
}
445447

446448
// Taskbar icon routine
447449
if (svcStatus.dwCurrentState != SERVICE_RUNNING)

0 commit comments

Comments
 (0)