mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 20:53:02 +00:00
[EVENTVWR] DisplayEvent(): Avoid using multiple large statically-sized buffers
CORE-20023 And use a loop to fill the individual event item fields, instead of repeating the same code over and over.
This commit is contained in:
parent
6829350af9
commit
85a69768d0
1 changed files with 26 additions and 24 deletions
|
@ -54,19 +54,21 @@ DisplayEvent(
|
||||||
_In_ HWND hDlg,
|
_In_ HWND hDlg,
|
||||||
_In_ PDETAILDATA pDetailData)
|
_In_ PDETAILDATA pDetailData)
|
||||||
{
|
{
|
||||||
|
/* Mapping of ListView column index to corresponding dialog control ID */
|
||||||
|
static const WORD lvColsToDlgItemIDs[] =
|
||||||
|
{
|
||||||
|
IDC_EVENTTYPESTATIC, IDC_EVENTDATESTATIC, IDC_EVENTTIMESTATIC,
|
||||||
|
IDC_EVENTSOURCESTATIC, IDC_EVENTCATEGORYSTATIC, IDC_EVENTIDSTATIC,
|
||||||
|
IDC_EVENTUSERSTATIC, IDC_EVENTCOMPUTERSTATIC,
|
||||||
|
};
|
||||||
|
|
||||||
PEVENTLOGRECORD pevlr;
|
PEVENTLOGRECORD pevlr;
|
||||||
PEVENTLOGFILTER EventLogFilter = pDetailData->EventLogFilter;
|
PEVENTLOGFILTER EventLogFilter = pDetailData->EventLogFilter;
|
||||||
INT iItem = pDetailData->iEventItem;
|
INT iItem = pDetailData->iEventItem;
|
||||||
|
USHORT i;
|
||||||
BOOL bEventData;
|
BOOL bEventData;
|
||||||
|
|
||||||
WCHAR szEventType[MAX_PATH];
|
|
||||||
WCHAR szTime[MAX_PATH];
|
|
||||||
WCHAR szDate[MAX_PATH];
|
|
||||||
WCHAR szUser[MAX_PATH];
|
|
||||||
WCHAR szComputer[MAX_PATH];
|
|
||||||
WCHAR szSource[MAX_PATH];
|
WCHAR szSource[MAX_PATH];
|
||||||
WCHAR szCategory[MAX_PATH];
|
|
||||||
WCHAR szEventID[MAX_PATH];
|
|
||||||
WCHAR szEventText[EVENT_MESSAGE_EVENTTEXT_BUFFER];
|
WCHAR szEventText[EVENT_MESSAGE_EVENTTEXT_BUFFER];
|
||||||
|
|
||||||
/* Retrieve and cache the pointer to the selected event item */
|
/* Retrieve and cache the pointer to the selected event item */
|
||||||
|
@ -77,23 +79,23 @@ DisplayEvent(
|
||||||
ListView_GetItem(hwndListView, &li);
|
ListView_GetItem(hwndListView, &li);
|
||||||
pevlr = pDetailData->pevlr = (PEVENTLOGRECORD)li.lParam;
|
pevlr = pDetailData->pevlr = (PEVENTLOGRECORD)li.lParam;
|
||||||
|
|
||||||
ListView_GetItemText(hwndListView, iItem, 0, szEventType, ARRAYSIZE(szEventType));
|
for (i = 0; i < _countof(lvColsToDlgItemIDs); ++i)
|
||||||
ListView_GetItemText(hwndListView, iItem, 1, szDate, ARRAYSIZE(szDate));
|
{
|
||||||
ListView_GetItemText(hwndListView, iItem, 2, szTime, ARRAYSIZE(szTime));
|
PWSTR pszBuffer = szEventText;
|
||||||
ListView_GetItemText(hwndListView, iItem, 3, szSource, ARRAYSIZE(szSource));
|
if (lvColsToDlgItemIDs[i] == IDC_EVENTSOURCESTATIC)
|
||||||
ListView_GetItemText(hwndListView, iItem, 4, szCategory, ARRAYSIZE(szCategory));
|
{
|
||||||
ListView_GetItemText(hwndListView, iItem, 5, szEventID, ARRAYSIZE(szEventID));
|
/* Use a separate buffer to store the source; used below */
|
||||||
ListView_GetItemText(hwndListView, iItem, 6, szUser, ARRAYSIZE(szUser));
|
pszBuffer = szSource;
|
||||||
ListView_GetItemText(hwndListView, iItem, 7, szComputer, ARRAYSIZE(szComputer));
|
ListView_GetItemText(hwndListView, iItem, i,
|
||||||
|
szSource, _countof(szSource));
|
||||||
SetDlgItemTextW(hDlg, IDC_EVENTDATESTATIC, szDate);
|
}
|
||||||
SetDlgItemTextW(hDlg, IDC_EVENTTIMESTATIC, szTime);
|
else
|
||||||
SetDlgItemTextW(hDlg, IDC_EVENTUSERSTATIC, szUser);
|
{
|
||||||
SetDlgItemTextW(hDlg, IDC_EVENTSOURCESTATIC, szSource);
|
ListView_GetItemText(hwndListView, iItem, i,
|
||||||
SetDlgItemTextW(hDlg, IDC_EVENTCOMPUTERSTATIC, szComputer);
|
szEventText, _countof(szEventText));
|
||||||
SetDlgItemTextW(hDlg, IDC_EVENTCATEGORYSTATIC, szCategory);
|
}
|
||||||
SetDlgItemTextW(hDlg, IDC_EVENTIDSTATIC, szEventID);
|
SetDlgItemTextW(hDlg, lvColsToDlgItemIDs[i], pszBuffer);
|
||||||
SetDlgItemTextW(hDlg, IDC_EVENTTYPESTATIC, szEventType);
|
}
|
||||||
|
|
||||||
bEventData = (pevlr->DataLength > 0);
|
bEventData = (pevlr->DataLength > 0);
|
||||||
EnableDlgItem(hDlg, IDC_BYTESRADIO, bEventData);
|
EnableDlgItem(hDlg, IDC_BYTESRADIO, bEventData);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue