[EVENTVWR] Simplify some duplicated code. (#4745)

This commit is contained in:
Hermès Bélusca-Maïto 2022-10-03 02:26:20 +02:00
parent 89bdca6177
commit efd11b7f56
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 28 additions and 40 deletions

View file

@ -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;

View file

@ -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));