Skip to content

Commit

Permalink
Add Tab and Esc key handling to main window and fix controls order
Browse files Browse the repository at this point in the history
  • Loading branch information
redddcyclone committed Jan 19, 2024
1 parent 2fb5a09 commit 6765363
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Future release
* Settings dialog added
Currently, the only setting available is "New ticket page URL", for
changing the URL used to create new tickets (i.e. when using Form Creator)

* Main window now handles Tab and Esc key pressing
This is a helpful feature for keyboard-only navigation

1.2.3

Expand Down
15 changes: 11 additions & 4 deletions GLPI-AgentMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ VOID CALLBACK UpdateServiceStatus(HWND hWnd, UINT message, UINT idTimer, DWORD d
colorSvcStatus = RGB(255, 0, 0);
SetDlgItemText(hWnd, IDC_SERVICESTATUS, szBuffer);
SetDlgItemText(hWnd, IDC_BTN_STARTSTOPSVC, szBtnString);
EnableWindow(GetDlgItem(hWnd, IDC_BTN_STARTSTOPSVC), FALSE);
HWND hWndSvcButton = GetDlgItem(hWnd, IDC_BTN_STARTSTOPSVC);
EnableWindow(hWndSvcButton, FALSE);
SetFocus(hWndSvcButton);
}

LoadIconMetric(hInst, MAKEINTRESOURCE(IDI_GLPIERR), LIM_LARGE, &nid.hIcon);
Expand Down Expand Up @@ -369,7 +371,9 @@ VOID CALLBACK UpdateServiceStatus(HWND hWnd, UINT message, UINT idTimer, DWORD d
LoadString(hInst, (svcStatus.dwCurrentState == SERVICE_STOPPED ? IDS_ERR_NOTRUNNING : IDS_WAIT), szBuffer, dwBufferLen);
SetDlgItemText(hWnd, IDC_AGENTSTATUS, szBuffer);

EnableWindow(GetDlgItem(hWnd, IDC_BTN_STARTSTOPSVC), bEnableButton);
HWND hWndSvcButton = GetDlgItem(hWnd, IDC_BTN_STARTSTOPSVC);
EnableWindow(hWndSvcButton, bEnableButton);
SetFocus(hWndSvcButton);

// Taskbar icon routine
if (svcStatus.dwCurrentState != SERVICE_RUNNING)
Expand Down Expand Up @@ -841,8 +845,10 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance
MSG msg;
while (GetMessage(&msg, nullptr, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
if (!IsDialogMessage(hWnd, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

CloseServiceHandle(hSc);
Expand Down Expand Up @@ -976,6 +982,7 @@ LRESULT CALLBACK DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
ForceInventory(hWnd);
return TRUE;
// Close
case IDCANCEL: // This handles ESC key pressing via IsDialogMessage
case IDC_BTN_CLOSE:
EndDialog(hWnd, NULL);
return TRUE;
Expand Down
6 changes: 3 additions & 3 deletions GLPI-AgentMonitor.rc
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,6 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTI
CAPTION "IDS_APP_TITLE"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "IDS_FORCEINV",IDC_BTN_FORCE,44,248,72,16
PUSHBUTTON "IDS_CLOSE",IDC_BTN_CLOSE,88,296,72,16
CTEXT "IDS_APP_TITLE",IDC_STATIC_TITLE,17,76,215,8
CTEXT "vX.XX",IDC_VERSION,17,87,215,8
GROUPBOX "IDS_STATIC_INFO",IDC_GBMAIN,7,100,235,103
Expand All @@ -497,10 +495,12 @@ BEGIN
RTEXT "IDS_LOADING",IDC_SERVICESTATUS,104,139,124,8
RTEXT "IDS_LOADING",IDC_STARTTYPE,100,157,128,8
CONTROL "",IDC_PCLOGO,"Static",SS_BITMAP,94,9,15,13
DEFPUSHBUTTON "IDS_STARTSVC",IDC_BTN_STARTSTOPSVC,82,177,86,16
PUSHBUTTON "IDS_FORCEINV",IDC_BTN_FORCE,44,248,72,16
PUSHBUTTON "IDS_NEWTICKET",IDC_BTN_NEWTICKET,132,248,72,16
PUSHBUTTON "IDS_VIEWLOGS",IDC_BTN_VIEWLOGS,44,272,72,16
PUSHBUTTON "IDS_STARTSVC",IDC_BTN_STARTSTOPSVC,82,177,86,16
PUSHBUTTON "IDS_BTN_SETTINGS",IDC_BTN_SETTINGS,132,272,72,16
PUSHBUTTON "IDS_CLOSE",IDC_BTN_CLOSE,88,296,72,16
END

IDD_DLG_SETTINGS DIALOGEX 0, 0, 357, 69
Expand Down

0 comments on commit 6765363

Please sign in to comment.