Skip to content

Commit 1786a68

Browse files
authored
[EVENTVWR] Localize and check item count (reactos#7757)
Don’t display garbage to the users. JIRA issue: CORE-19786 - Localize message text by using newly added IDS_CONTFROMBEGINNING and IDS_CONTFROMEND resource strings. - Check item count before showing next/previous item. - Add EnableEventDetailsButtons function.
1 parent 0898bd3 commit 1786a68

29 files changed

+86
-23
lines changed

base/applications/mscutils/eventvwr/eventvwr.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1978,6 +1978,7 @@ EnumEventsThread(IN LPVOID lpParameter)
19781978
BOOL bResult = TRUE; /* Read succeeded */
19791979
HANDLE hProcessHeap = GetProcessHeap();
19801980
PSID pLastSid = NULL;
1981+
INT nItems;
19811982

19821983
UINT uStep = 0, uStepAt = 0, uPos = 0;
19831984

@@ -1997,11 +1998,12 @@ EnumEventsThread(IN LPVOID lpParameter)
19971998
SYSTEMTIME time;
19981999
LVITEMW lviEventItem;
19992000

2001+
EnableEventDetailsButtons(hwndEventDetails, FALSE);
2002+
20002003
/* Save the current event log filter globally */
20012004
EventLogFilter_AddRef(EventLogFilter);
20022005
ActiveFilter = EventLogFilter;
20032006

2004-
20052007
/** HACK!! **/
20062008
EventLog = EventLogFilter->EventLogs[0];
20072009

@@ -2263,6 +2265,8 @@ EnumEventsThread(IN LPVOID lpParameter)
22632265
/* All events loaded */
22642266

22652267
Cleanup:
2268+
nItems = ListView_GetItemCount(hwndListView);
2269+
EnableEventDetailsButtons(hwndEventDetails, (nItems > 0));
22662270

22672271
ShowWindow(hwndStatusProgress, SW_HIDE);
22682272
SendMessageW(hwndListView, LVM_PROGRESS, 0, FALSE);

base/applications/mscutils/eventvwr/evtdetctl.c

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,11 @@ EventDetailsCtrl(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
792792
pData->EventLogFilter = DetailInfo->EventLogFilter;
793793
pData->iEventItem = DetailInfo->iEventItem;
794794
}
795+
else
796+
{
797+
pData->iEventItem = -1;
798+
}
799+
795800
pData->bDisplayWords = FALSE;
796801
pData->hMonospaceFont = CreateMonospaceFont();
797802

@@ -838,31 +843,26 @@ EventDetailsCtrl(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
838843
case IDC_NEXT:
839844
{
840845
BOOL bPrev = (LOWORD(wParam) == IDC_PREVIOUS);
841-
INT iItem, iSel;
846+
INT iItem, iSel, nItems = ListView_GetItemCount(hwndListView);
847+
WCHAR szText[200];
848+
849+
if (nItems <= 0) /* No items? */
850+
break;
842851

843852
/* Select the previous/next item from our current one */
844-
iItem = ListView_GetNextItem(hwndListView,
845-
pData->iEventItem,
846-
bPrev ? LVNI_ABOVE : LVNI_BELOW);
847-
if (iItem == -1)
853+
iItem = ListView_GetNextItem(hwndListView, -1, LVNI_ALL | LVNI_SELECTED);
854+
iItem = ListView_GetNextItem(hwndListView, iItem,
855+
(bPrev ? LVNI_ABOVE : LVNI_BELOW));
856+
if (iItem < 0 || iItem >= nItems)
848857
{
849-
// TODO: Localization.
850-
if (MessageBoxW(hDlg,
851-
bPrev
852-
? L"You have reached the beginning of the event log. Do you want to continue from the end?"
853-
: L"You have reached the end of the event log. Do you want to continue from the beginning?",
854-
szTitle,
855-
MB_YESNO | MB_ICONQUESTION)
856-
== IDNO)
857-
{
858+
LoadStringW(hInst,
859+
(bPrev ? IDS_CONTFROMEND : IDS_CONTFROMBEGINNING),
860+
szText, _countof(szText));
861+
if (MessageBoxW(hDlg, szText, szTitle, MB_YESNO | MB_ICONQUESTION) == IDNO)
858862
break;
859-
}
860863

861864
/* Determine from where to restart */
862-
if (bPrev)
863-
iItem = ListView_GetItemCount(hwndListView) - 1;
864-
else
865-
iItem = 0;
865+
iItem = (bPrev ? (nItems - 1) : 0);
866866
}
867867

868868
/*
@@ -959,3 +959,11 @@ CreateEventDetailsCtrl(HINSTANCE hInstance,
959959
MAKEINTRESOURCEW(IDD_EVENTDETAILS_CTRL),
960960
hParentWnd, EventDetailsCtrl, lParam);
961961
}
962+
963+
VOID
964+
EnableEventDetailsButtons(HWND hWnd, BOOL bEnable)
965+
{
966+
EnableDlgItem(hWnd, IDC_PREVIOUS, bEnable);
967+
EnableDlgItem(hWnd, IDC_NEXT, bEnable);
968+
EnableDlgItem(hWnd, IDC_COPY, bEnable);
969+
}

base/applications/mscutils/eventvwr/evtdetctl.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
* Copyright 2016-2022 Hermès Bélusca-Maïto <[email protected]>
88
*/
99

10-
#ifndef _EVTDETCTL_H_
11-
#define _EVTDETCTL_H_
10+
#pragma once
1211

1312
/* Optional structure passed by pointer
1413
* as LPARAM to CreateEventDetailsCtrl() */
@@ -26,4 +25,4 @@ CreateEventDetailsCtrl(HINSTANCE hInstance,
2625
HWND hParentWnd,
2726
LPARAM lParam);
2827

29-
#endif /* _EVTDETCTL_H_ */
28+
VOID EnableEventDetailsButtons(HWND hWnd, BOOL bEnable);

base/applications/mscutils/eventvwr/lang/bg-BG.rc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ BEGIN
167167
IDS_CLEAREVENTS_MSG "Do you want to save this event log before clearing it?"
168168
IDS_RESTOREDEFAULTS "Do you want to restore all settings for this log to their default values?"
169169
IDS_EVENTSTRINGIDNOTFOUND "Не е намерено описанието на събитие ( %lu ) в източник ( %s ). Възможно е местият компютър да няма нужните сведения в регистъра или DLL файловет, нужни за показване на съобщения от отдалечен компютър.\n\nThe following information is part of the event:\n\n"
170+
IDS_CONTFROMBEGINNING "You have reached the end of the event log. Do you want to continue from the beginning?"
171+
IDS_CONTFROMEND "You have reached the beginning of the event log. Do you want to continue from the end?"
170172
END
171173

172174
STRINGTABLE

base/applications/mscutils/eventvwr/lang/cs-CZ.rc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ BEGIN
167167
IDS_CLEAREVENTS_MSG "Chcete tento protokol před odstraněním uložit?"
168168
IDS_RESTOREDEFAULTS "Do you want to restore all settings for this log to their default values?"
169169
IDS_EVENTSTRINGIDNOTFOUND "Popis ID události ( %lu ) zdroj ( %s ) nebyl nalezen. Místní počítač neobsahuje potřebné informace v registru nebo chybí DLL soubory pro zobrazení zpráv ze vzdáleného počítače.\n\nThe following information is part of the event:\n\n"
170+
IDS_CONTFROMBEGINNING "You have reached the end of the event log. Do you want to continue from the beginning?"
171+
IDS_CONTFROMEND "You have reached the beginning of the event log. Do you want to continue from the end?"
170172
END
171173

172174
STRINGTABLE

base/applications/mscutils/eventvwr/lang/de-DE.rc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ BEGIN
168168
IDS_CLEAREVENTS_MSG "Möchten Sie dieses Protokoll vor dem Löschen speichern?"
169169
IDS_RESTOREDEFAULTS "Möchten Sie alle Einstellungen für dieses Protokoll wieder auf die Standardwerte zurücksetzen?"
170170
IDS_EVENTSTRINGIDNOTFOUND "Die Bezeichnung für die Ereignis-ID ( %lu ) in der Quelle ( %s ) kann nicht gefunden werden. Es könnte sein, dass der lokale Computer die notwendigen Registry Einträge oder Nachrichten DLLs, um Nachrichten entfernter Computer anzuzeigen, nicht besitzt.\n\nDas Ereignis enthält folgende Informationen:\n\n"
171+
IDS_CONTFROMBEGINNING "You have reached the end of the event log. Do you want to continue from the beginning?"
172+
IDS_CONTFROMEND "You have reached the beginning of the event log. Do you want to continue from the end?"
171173
END
172174

173175
STRINGTABLE

base/applications/mscutils/eventvwr/lang/el-GR.rc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ BEGIN
167167
IDS_CLEAREVENTS_MSG "Do you want to save this event log before clearing it?"
168168
IDS_RESTOREDEFAULTS "Do you want to restore all settings for this log to their default values?"
169169
IDS_EVENTSTRINGIDNOTFOUND "The description for Event ID ( %lu ) in Source ( %s ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer.\n\nThe following information is part of the event:\n\n"
170+
IDS_CONTFROMBEGINNING "You have reached the end of the event log. Do you want to continue from the beginning?"
171+
IDS_CONTFROMEND "You have reached the beginning of the event log. Do you want to continue from the end?"
170172
END
171173

172174
STRINGTABLE

base/applications/mscutils/eventvwr/lang/en-US.rc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ BEGIN
169169
IDS_CLEAREVENTS_MSG "Do you want to save this event log before clearing it?"
170170
IDS_RESTOREDEFAULTS "Do you want to restore all settings for this log to their default values?"
171171
IDS_EVENTSTRINGIDNOTFOUND "The description for Event ID ( %lu ) in Source ( %s ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer.\n\nThe following information is part of the event:\n\n"
172+
IDS_CONTFROMBEGINNING "You have reached the end of the event log. Do you want to continue from the beginning?"
173+
IDS_CONTFROMEND "You have reached the beginning of the event log. Do you want to continue from the end?"
172174
END
173175

174176
STRINGTABLE

base/applications/mscutils/eventvwr/lang/es-ES.rc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ BEGIN
170170
IDS_CLEAREVENTS_MSG "¿Desea guardar este registro de eventos antes de borrarlo?"
171171
IDS_RESTOREDEFAULTS "Do you want to restore all settings for this log to their default values?"
172172
IDS_EVENTSTRINGIDNOTFOUND "No se pudo recuperar la descripción para el evento con ID ( %lu ) y origen ( %s ). El equipo local puede no tener la información necesaria en el registro o las DLLs necesarias para mostrar los mensajes de un equipo remoto.\n\nLa siguiente información es parte del evento:\n\n"
173+
IDS_CONTFROMBEGINNING "You have reached the end of the event log. Do you want to continue from the beginning?"
174+
IDS_CONTFROMEND "You have reached the beginning of the event log. Do you want to continue from the end?"
173175
END
174176

175177
STRINGTABLE

base/applications/mscutils/eventvwr/lang/fr-FR.rc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ BEGIN
168168
IDS_CLEAREVENTS_MSG "Voulez-vous enregistrer ce journal d'événements avant de l'effacer ?"
169169
IDS_RESTOREDEFAULTS "Voulez-vous vraiment réinitialiser tous les paramètres pour ce journal aux valeurs par défaut ?"
170170
IDS_EVENTSTRINGIDNOTFOUND "La description pour l'événement d'ID ( %lu ) dans la source ( %s ) ne peut être trouvée. L'ordinateur local pourrait ne pas avoir les informations registres nécessaires ou les fichiers DLL de message pour afficher les messages depuis un ordinateur distant.\n\nLes informations suivantes font partie de l'événement :\n\n"
171+
IDS_CONTFROMBEGINNING "You have reached the end of the event log. Do you want to continue from the beginning?"
172+
IDS_CONTFROMEND "You have reached the beginning of the event log. Do you want to continue from the end?"
171173
END
172174

173175
STRINGTABLE

0 commit comments

Comments
 (0)