https://git.reactos.org/?p=reactos.git;a=commitdiff;h=efd11b7f5672319d45492…
commit efd11b7f5672319d45492aee04cbd133c1d09a85
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Mon Oct 3 02:26:20 2022 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Oct 3 23:17:02 2022 +0200
[EVENTVWR] Simplify some duplicated code. (#4745)
---
base/applications/mscutils/eventvwr/eventvwr.c | 42 ++++++++++---------------
base/applications/mscutils/eventvwr/evtdetctl.c | 26 +++++++--------
2 files changed, 28 insertions(+), 40 deletions(-)
diff --git a/base/applications/mscutils/eventvwr/eventvwr.c
b/base/applications/mscutils/eventvwr/eventvwr.c
index 1d5328fc222..a35daffab26 100644
--- a/base/applications/mscutils/eventvwr/eventvwr.c
+++ b/base/applications/mscutils/eventvwr/eventvwr.c
@@ -33,8 +33,8 @@ static const LPCWSTR SystemLogs[] =
};
/* MessageFile message buffer size */
-#define EVENT_MESSAGE_EVENTTEXT_BUFFER 1024*10 // NOTE: Used
by evtdetctl.c
-#define EVENT_MESSAGE_FILE_BUFFER 1024*10
+#define EVENT_MESSAGE_EVENTTEXT_BUFFER (1024*10) // NOTE: Used
by evtdetctl.c
+#define EVENT_MESSAGE_FILE_BUFFER (1024*10)
#define EVENT_DLL_SEPARATOR L";"
#define EVENT_CATEGORY_MESSAGE_FILE L"CategoryMessageFile"
#define EVENT_MESSAGE_FILE L"EventMessageFile"
@@ -2034,7 +2034,7 @@ EnumEventsThread(IN LPVOID lpParameter)
// (EventLogFilter->NumOfEventLogs > 1)
MessageBoxW(hwndMainWindow,
L"Many-logs filtering is not implemented yet!!",
- L"Event Log",
+ szTitle,
MB_OK | MB_ICONINFORMATION);
}
@@ -3514,22 +3514,14 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
case IDM_LIST_NEWEST:
- {
- CheckMenuRadioItem(hMainMenu, IDM_LIST_NEWEST, IDM_LIST_OLDEST,
IDM_LIST_NEWEST, MF_BYCOMMAND);
- if (!Settings.bNewestEventsFirst)
- {
- Settings.bNewestEventsFirst = TRUE;
- Refresh(GetSelectedFilter(NULL));
- }
- break;
- }
-
case IDM_LIST_OLDEST:
{
- CheckMenuRadioItem(hMainMenu, IDM_LIST_NEWEST, IDM_LIST_OLDEST,
IDM_LIST_OLDEST, MF_BYCOMMAND);
- if (Settings.bNewestEventsFirst)
+ BOOL bNewest = (LOWORD(wParam) == IDM_LIST_NEWEST);
+ CheckMenuRadioItem(hMainMenu, IDM_LIST_NEWEST, IDM_LIST_OLDEST,
LOWORD(wParam), MF_BYCOMMAND);
+
+ if (bNewest != Settings.bNewestEventsFirst)
{
- Settings.bNewestEventsFirst = FALSE;
+ Settings.bNewestEventsFirst = bNewest;
Refresh(GetSelectedFilter(NULL));
}
break;
@@ -3608,11 +3600,11 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
case IDM_HELP:
- MessageBoxW(hwndMainWindow,
+ MessageBoxW(hWnd,
L"Help not implemented yet!",
- L"Event Log",
+ szTitle,
MB_OK | MB_ICONINFORMATION);
- break;
+ break;
case IDM_EXIT:
DestroyWindow(hWnd);
@@ -4192,7 +4184,7 @@ EventLogPropProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
lParam)
case IDHELP:
MessageBoxW(hDlg,
L"Help not implemented yet!",
- L"Event Log",
+ szTitle,
MB_OK | MB_ICONINFORMATION);
return (INT_PTR)TRUE;
@@ -4279,7 +4271,6 @@ EventDetails(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_INITDIALOG:
{
LONG_PTR dwStyle;
- INT sbVXSize, sbHYSize;
RECT rcWnd, rect;
hWndDetailsCtrl = CreateEventDetailsCtrl(hInst, hDlg, lParam);
@@ -4291,11 +4282,12 @@ EventDetails(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
/* Create a size grip if the dialog has a sizing border */
GetClientRect(hDlg, &rcWnd);
- dwStyle = GetWindowLongPtrW(hDlg, GWL_STYLE);
- sbVXSize = GetSystemMetrics(SM_CXVSCROLL);
- sbHYSize = GetSystemMetrics(SM_CYHSCROLL);
+ dwStyle = GetWindowLongPtrW(hDlg, GWL_STYLE);
if (dwStyle & WS_THICKFRAME /* == WS_SIZEBOX */)
{
+ INT sbVXSize = GetSystemMetrics(SM_CXVSCROLL);
+ INT sbHYSize = GetSystemMetrics(SM_CYHSCROLL);
+
hWndGrip = CreateWindowW(WC_SCROLLBARW,
NULL,
WS_CHILD | WS_VISIBLE | /**/ WS_CLIPSIBLINGS |
/**/ SBS_SIZEGRIP | SBS_SIZEBOXBOTTOMRIGHTALIGN,
@@ -4380,7 +4372,7 @@ EventDetails(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
case IDHELP:
MessageBoxW(hDlg,
L"Help not implemented yet!",
- L"Event Log",
+ szTitle,
MB_OK | MB_ICONINFORMATION);
return (INT_PTR)TRUE;
diff --git a/base/applications/mscutils/eventvwr/evtdetctl.c
b/base/applications/mscutils/eventvwr/evtdetctl.c
index ef11ce4bf33..4cc6f9752cf 100644
--- a/base/applications/mscutils/eventvwr/evtdetctl.c
+++ b/base/applications/mscutils/eventvwr/evtdetctl.c
@@ -13,7 +13,7 @@
#include <shellapi.h>
// FIXME:
-#define EVENT_MESSAGE_EVENTTEXT_BUFFER 1024*10
+#define EVENT_MESSAGE_EVENTTEXT_BUFFER (1024*10)
extern HWND hwndListView;
extern BOOL
GetEventMessage(IN LPCWSTR KeyName,
@@ -479,7 +479,8 @@ OnScroll(HWND hDlg, PDETAILDATA pData, INT nBar, WORD sbCode)
}
}
-static VOID
+static
+VOID
OnSize(HWND hDlg, PDETAILDATA pData, INT cx, INT cy)
{
LONG_PTR dwStyle;
@@ -877,20 +878,15 @@ EventDetailsCtrl(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
lParam)
return (INT_PTR)TRUE;
case IDC_BYTESRADIO:
- if (pData->EventLogFilter)
- {
- pData->bDisplayWords = FALSE;
- DisplayEventData(hDlg, pData->bDisplayWords);
- }
- return (INT_PTR)TRUE;
-
case IDC_WORDRADIO:
+ {
if (pData->EventLogFilter)
{
- pData->bDisplayWords = TRUE;
+ pData->bDisplayWords = (LOWORD(wParam) == IDC_WORDRADIO);
DisplayEventData(hDlg, pData->bDisplayWords);
}
return (INT_PTR)TRUE;
+ }
default:
break;
@@ -914,14 +910,14 @@ EventDetailsCtrl(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
lParam)
}
case WM_HSCROLL:
- OnScroll(hDlg, pData, SB_HORZ, LOWORD(wParam));
- SetWindowLongPtrW(hDlg, DWLP_MSGRESULT, 0);
- return (INT_PTR)TRUE;
-
case WM_VSCROLL:
- OnScroll(hDlg, pData, SB_VERT, LOWORD(wParam));
+ {
+ OnScroll(hDlg, pData,
+ (uMsg == WM_HSCROLL) ? SB_HORZ : SB_VERT,
+ LOWORD(wParam));
SetWindowLongPtrW(hDlg, DWLP_MSGRESULT, 0);
return (INT_PTR)TRUE;
+ }
case WM_SIZE:
OnSize(hDlg, pData, LOWORD(lParam), HIWORD(lParam));