[EVENTVWR] Code style only.

This commit is contained in:
Hermès Bélusca-Maïto 2018-04-17 22:43:47 +02:00
parent fd3a6c1089
commit 0c32666852
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 105 additions and 97 deletions

View file

@ -37,8 +37,8 @@
#define LVM_PROGRESS (WM_APP + 1) // Used by the subclassed ListView #define LVM_PROGRESS (WM_APP + 1) // Used by the subclassed ListView
static const LPCWSTR szWindowClass = L"EVENTVWR"; /* The main window class name */ static const LPCWSTR EVENTVWR_WNDCLASS = L"EVENTVWR"; /* The main window class name */
static const WCHAR EVENTLOG_BASE_KEY[] = L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\"; static const LPCWSTR EVENTLOG_BASE_KEY = L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\";
/* The 3 system logs that should always exist in the user's system */ /* The 3 system logs that should always exist in the user's system */
static const LPCWSTR SystemLogs[] = static const LPCWSTR SystemLogs[] =
@ -442,6 +442,7 @@ wWinMain(HINSTANCE hInstance,
} }
} }
/* Stop the enumerator thread */
SetEvent(hStartStopEnumEvent); SetEvent(hStartStopEnumEvent);
WaitForSingleObject(hThread, INFINITE); WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread); CloseHandle(hThread);
@ -1217,7 +1218,7 @@ GetEventMessageFileDLL(IN LPCWSTR lpLogName,
{ {
BOOL Success = FALSE; BOOL Success = FALSE;
LONG Result; LONG Result;
DWORD Type, dwSize; DWORD dwType, dwSize;
WCHAR szModuleName[MAX_PATH]; WCHAR szModuleName[MAX_PATH];
WCHAR szKeyName[MAX_PATH]; WCHAR szKeyName[MAX_PATH];
HKEY hLogKey = NULL; HKEY hLogKey = NULL;
@ -1249,10 +1250,10 @@ GetEventMessageFileDLL(IN LPCWSTR lpLogName,
Result = RegQueryValueExW(hSourceKey, Result = RegQueryValueExW(hSourceKey,
EntryName, EntryName,
NULL, NULL,
&Type, &dwType,
(LPBYTE)szModuleName, (LPBYTE)szModuleName,
&dwSize); &dwSize);
if ((Result != ERROR_SUCCESS) || (Type != REG_EXPAND_SZ && Type != REG_SZ)) if ((Result != ERROR_SUCCESS) || (dwType != REG_EXPAND_SZ && dwType != REG_SZ))
{ {
szModuleName[0] = UNICODE_NULL; szModuleName[0] = UNICODE_NULL;
} }
@ -1829,7 +1830,7 @@ EnumEventsThread(IN LPVOID lpParameter)
} }
else if (!bResult) else if (!bResult)
{ {
/* exit on other errors (ERROR_HANDLE_EOF) */ /* Exit on other errors (ERROR_HANDLE_EOF) */
break; break;
} }
@ -2378,7 +2379,7 @@ MyRegisterClass(HINSTANCE hInstance)
wcex.hCursor = LoadCursorW(NULL, MAKEINTRESOURCEW(IDC_ARROW)); wcex.hCursor = LoadCursorW(NULL, MAKEINTRESOURCEW(IDC_ARROW));
wcex.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); // COLOR_WINDOW + 1 wcex.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); // COLOR_WINDOW + 1
wcex.lpszMenuName = MAKEINTRESOURCEW(IDM_EVENTVWR); wcex.lpszMenuName = MAKEINTRESOURCEW(IDM_EVENTVWR);
wcex.lpszClassName = szWindowClass; wcex.lpszClassName = EVENTVWR_WNDCLASS;
wcex.hIconSm = (HICON)LoadImageW(hInstance, wcex.hIconSm = (HICON)LoadImageW(hInstance,
MAKEINTRESOURCEW(IDI_EVENTVWR), MAKEINTRESOURCEW(IDI_EVENTVWR),
IMAGE_ICON, IMAGE_ICON,
@ -2400,7 +2401,7 @@ GetDisplayNameFileAndID(IN LPCWSTR lpLogName,
HKEY hLogKey; HKEY hLogKey;
WCHAR *KeyPath; WCHAR *KeyPath;
SIZE_T cbKeyPath; SIZE_T cbKeyPath;
DWORD Type, cbData; DWORD dwType, cbData;
DWORD dwMessageID = 0; DWORD dwMessageID = 0;
WCHAR szModuleName[MAX_PATH]; WCHAR szModuleName[MAX_PATH];
@ -2424,10 +2425,10 @@ GetDisplayNameFileAndID(IN LPCWSTR lpLogName,
Result = RegQueryValueExW(hLogKey, Result = RegQueryValueExW(hLogKey,
L"DisplayNameFile", L"DisplayNameFile",
NULL, NULL,
&Type, &dwType,
(LPBYTE)szModuleName, (LPBYTE)szModuleName,
&cbData); &cbData);
if ((Result != ERROR_SUCCESS) || (Type != REG_EXPAND_SZ && Type != REG_SZ)) if ((Result != ERROR_SUCCESS) || (dwType != REG_EXPAND_SZ && dwType != REG_SZ))
{ {
szModuleName[0] = UNICODE_NULL; szModuleName[0] = UNICODE_NULL;
} }
@ -2449,10 +2450,10 @@ GetDisplayNameFileAndID(IN LPCWSTR lpLogName,
Result = RegQueryValueExW(hLogKey, Result = RegQueryValueExW(hLogKey,
L"DisplayNameID", L"DisplayNameID",
NULL, NULL,
&Type, &dwType,
(LPBYTE)&dwMessageID, (LPBYTE)&dwMessageID,
&cbData); &cbData);
if ((Result != ERROR_SUCCESS) || (Type != REG_DWORD)) if ((Result != ERROR_SUCCESS) || (dwType != REG_DWORD))
dwMessageID = 0; dwMessageID = 0;
*pdwMessageID = dwMessageID; *pdwMessageID = dwMessageID;
@ -2471,7 +2472,7 @@ BuildLogListAndFilterList(IN LPCWSTR lpComputerName)
HKEY hEventLogKey, hLogKey; HKEY hEventLogKey, hLogKey;
DWORD dwNumLogs = 0; DWORD dwNumLogs = 0;
DWORD dwIndex, dwMaxKeyLength; DWORD dwIndex, dwMaxKeyLength;
DWORD Type; DWORD dwType;
PEVENTLOG EventLog; PEVENTLOG EventLog;
PEVENTLOGFILTER EventLogFilter; PEVENTLOGFILTER EventLogFilter;
LPWSTR LogName = NULL; LPWSTR LogName = NULL;
@ -2554,10 +2555,10 @@ BuildLogListAndFilterList(IN LPCWSTR lpComputerName)
Result = RegQueryValueExW(hLogKey, Result = RegQueryValueExW(hLogKey,
L"File", L"File",
NULL, NULL,
&Type, &dwType,
NULL, NULL,
&lpcName); &lpcName);
if ((Result != ERROR_SUCCESS) || (Type != REG_EXPAND_SZ && Type != REG_SZ)) if ((Result != ERROR_SUCCESS) || (dwType != REG_EXPAND_SZ && dwType != REG_SZ))
{ {
// Windows' EventLog uses some kind of default value, we do not. // Windows' EventLog uses some kind of default value, we do not.
EventLog->FileName = NULL; EventLog->FileName = NULL;
@ -2571,7 +2572,7 @@ BuildLogListAndFilterList(IN LPCWSTR lpComputerName)
Result = RegQueryValueExW(hLogKey, Result = RegQueryValueExW(hLogKey,
L"File", L"File",
NULL, NULL,
&Type, &dwType,
(LPBYTE)EventLog->FileName, (LPBYTE)EventLog->FileName,
&lpcName); &lpcName);
if (Result != ERROR_SUCCESS) if (Result != ERROR_SUCCESS)
@ -2698,7 +2699,7 @@ InitInstance(HINSTANCE hInstance,
WCHAR szTemp[256]; WCHAR szTemp[256];
/* Create the main window */ /* Create the main window */
hwndMainWindow = CreateWindowW(szWindowClass, hwndMainWindow = CreateWindowW(EVENTVWR_WNDCLASS,
szTitle, szTitle,
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
@ -2731,7 +2732,7 @@ InitInstance(HINSTANCE hInstance,
NULL, // no text NULL, // no text
WS_CHILD | PBS_SMOOTH, // styles WS_CHILD | PBS_SMOOTH, // styles
rs.left, rs.top, // x, y rs.left, rs.top, // x, y
rs.right-rs.left, rs.bottom-rs.top, // cx, cy rs.right - rs.left, rs.bottom - rs.top, // cx, cy
hwndStatus, // parent window hwndStatus, // parent window
NULL, // window ID NULL, // window ID
hInstance, // instance hInstance, // instance
@ -3053,7 +3054,7 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
LPWSTR pszText = item.pszText; LPWSTR pszText = item.pszText;
/* Trim all whitespace */ /* Trim leading whitespace */
while (*pszText && iswspace(*pszText)) while (*pszText && iswspace(*pszText))
++pszText; ++pszText;
@ -3234,41 +3235,44 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
case WM_SETCURSOR: case WM_SETCURSOR:
if (LOWORD(lParam) == HTCLIENT) {
{ POINT pt;
POINT pt;
GetCursorPos(&pt);
ScreenToClient(hWnd, &pt);
/* Set the cursor for the vertical splitter */ if (LOWORD(lParam) != HTCLIENT)
if (pt.x >= nVSplitPos - SPLIT_WIDTH/2 && pt.x < nVSplitPos + SPLIT_WIDTH/2 + 1) goto Default;
GetCursorPos(&pt);
ScreenToClient(hWnd, &pt);
/* Set the cursor for the vertical splitter */
if (pt.x >= nVSplitPos - SPLIT_WIDTH/2 && pt.x < nVSplitPos + SPLIT_WIDTH/2 + 1)
{
RECT rs;
GetClientRect(hWnd, &rect);
GetWindowRect(hwndStatus, &rs);
if (pt.y >= rect.top && pt.y < rect.bottom - (rs.bottom - rs.top))
{ {
RECT rs; SetCursor(LoadCursorW(NULL, IDC_SIZEWE));
GetClientRect(hWnd, &rect); return TRUE;
GetWindowRect(hwndStatus, &rs);
if (pt.y >= rect.top && pt.y < rect.bottom - (rs.bottom - rs.top))
{
SetCursor(LoadCursorW(NULL, IDC_SIZEWE));
return TRUE;
}
} }
else }
/* Set the cursor for the horizontal splitter, if the Event details pane is displayed */ else
if (hwndEventDetails && /* Set the cursor for the horizontal splitter, if the Event details pane is displayed */
(pt.y >= nHSplitPos - SPLIT_WIDTH/2 && pt.y < nHSplitPos + SPLIT_WIDTH/2 + 1)) if (hwndEventDetails &&
(pt.y >= nHSplitPos - SPLIT_WIDTH/2 && pt.y < nHSplitPos + SPLIT_WIDTH/2 + 1))
{
// RECT rs;
GetClientRect(hWnd, &rect);
// GetWindowRect(hwndStatus, &rs);
if (pt.x >= nVSplitPos + SPLIT_WIDTH/2 + 1 /* rect.left + (rs.bottom - rs.top) */ &&
pt.x < rect.right)
{ {
// RECT rs; SetCursor(LoadCursorW(NULL, IDC_SIZENS));
GetClientRect(hWnd, &rect); return TRUE;
// GetWindowRect(hwndStatus, &rs);
if (pt.x >= nVSplitPos + SPLIT_WIDTH/2 + 1 /* rect.left + (rs.bottom - rs.top) */ &&
pt.x < rect.right)
{
SetCursor(LoadCursorW(NULL, IDC_SIZENS));
return TRUE;
}
} }
} }
goto Default; goto Default;
}
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
{ {
@ -3297,62 +3301,66 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_LBUTTONUP: case WM_LBUTTONUP:
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
if (GetCapture() == hWnd) {
if (GetCapture() != hWnd)
break;
/* Adjust the correct splitter position */
if (bSplit == 1)
nVSplitPos = GET_X_LPARAM(lParam);
else if (bSplit == 2)
nHSplitPos = GET_Y_LPARAM(lParam);
/* If we are splitting, resize the windows */
if (bSplit != 0)
{ {
/* Adjust the correct splitter position */ GetClientRect(hWnd, &rect);
if (bSplit == 1) ResizeWnd(rect.right - rect.left, rect.bottom - rect.top);
nVSplitPos = GET_X_LPARAM(lParam);
else if (bSplit == 2)
nHSplitPos = GET_Y_LPARAM(lParam);
/* If we are splitting, resize the windows */
if (bSplit != 0)
{
GetClientRect(hWnd, &rect);
ResizeWnd(rect.right - rect.left, rect.bottom - rect.top);
}
/* Reset the splitter state */
bSplit = 0;
ReleaseCapture();
} }
/* Reset the splitter state */
bSplit = 0;
ReleaseCapture();
break; break;
}
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
if (GetCapture() == hWnd) {
if (GetCapture() != hWnd)
break;
/* Move the correct splitter */
if (bSplit == 1)
{ {
/* Move the correct splitter */ INT x = GET_X_LPARAM(lParam);
if (bSplit == 1)
GetClientRect(hWnd, &rect);
x = min(max(x, SPLIT_WIDTH/2), rect.right - rect.left - SPLIT_WIDTH/2);
if (nVSplitPos != x)
{ {
INT x = GET_X_LPARAM(lParam); nVSplitPos = x;
ResizeWnd(rect.right - rect.left, rect.bottom - rect.top);
GetClientRect(hWnd, &rect);
x = min(max(x, SPLIT_WIDTH/2), rect.right - rect.left - SPLIT_WIDTH/2);
if (nVSplitPos != x)
{
nVSplitPos = x;
ResizeWnd(rect.right - rect.left, rect.bottom - rect.top);
}
} }
else if (bSplit == 2) }
else if (bSplit == 2)
{
RECT rs;
INT y = GET_Y_LPARAM(lParam);
GetClientRect(hWnd, &rect);
GetWindowRect(hwndStatus, &rs);
y = min(max(y, SPLIT_WIDTH/2), rect.bottom - rect.top - SPLIT_WIDTH/2 - (rs.bottom - rs.top));
if (nHSplitPos != y)
{ {
RECT rs; nHSplitPos = y;
INT y = GET_Y_LPARAM(lParam); ResizeWnd(rect.right - rect.left, rect.bottom - rect.top);
GetClientRect(hWnd, &rect);
GetWindowRect(hwndStatus, &rs);
y = min(max(y, SPLIT_WIDTH/2), rect.bottom - rect.top - SPLIT_WIDTH/2 - (rs.bottom - rs.top));
if (nHSplitPos != y)
{
nHSplitPos = y;
ResizeWnd(rect.right - rect.left, rect.bottom - rect.top);
}
} }
} }
break; break;
}
case WM_SIZE: case WM_SIZE:
{ {
@ -3379,7 +3387,7 @@ InitPropertiesDlg(HWND hDlg, PEVENTLOG EventLog)
{ {
LPWSTR lpLogName = EventLog->LogName; LPWSTR lpLogName = EventLog->LogName;
DWORD Result, Type; DWORD Result, dwType;
DWORD dwMaxSize = 0, dwRetention = 0; DWORD dwMaxSize = 0, dwRetention = 0;
BOOL Success; BOOL Success;
WIN32_FIND_DATAW FileInfo; // WIN32_FILE_ATTRIBUTE_DATA WIN32_FIND_DATAW FileInfo; // WIN32_FILE_ATTRIBUTE_DATA
@ -3418,10 +3426,10 @@ InitPropertiesDlg(HWND hDlg, PEVENTLOG EventLog)
Result = RegQueryValueExW(hLogKey, Result = RegQueryValueExW(hLogKey,
L"MaxSize", L"MaxSize",
NULL, NULL,
&Type, &dwType,
(LPBYTE)&dwMaxSize, (LPBYTE)&dwMaxSize,
&cbData); &cbData);
if ((Result != ERROR_SUCCESS) || (Type != REG_DWORD)) if ((Result != ERROR_SUCCESS) || (dwType != REG_DWORD))
{ {
// dwMaxSize = 512 * 1024; /* 512 kBytes */ // dwMaxSize = 512 * 1024; /* 512 kBytes */
dwMaxSize = 0; dwMaxSize = 0;
@ -3433,10 +3441,10 @@ InitPropertiesDlg(HWND hDlg, PEVENTLOG EventLog)
Result = RegQueryValueExW(hLogKey, Result = RegQueryValueExW(hLogKey,
L"Retention", L"Retention",
NULL, NULL,
&Type, &dwType,
(LPBYTE)&dwRetention, (LPBYTE)&dwRetention,
&cbData); &cbData);
if ((Result != ERROR_SUCCESS) || (Type != REG_DWORD)) if ((Result != ERROR_SUCCESS) || (dwType != REG_DWORD))
{ {
/* On Windows 2003 it is 604800 (secs) == 7 days */ /* On Windows 2003 it is 604800 (secs) == 7 days */
dwRetention = 0; dwRetention = 0;

View file

@ -730,7 +730,7 @@ InitDetailsDlgCtrl(HWND hDlg, PDETAILDATA pData)
*/ */
SendDlgItemMessageW(hDlg, IDC_EVENTTEXTEDIT, EM_AUTOURLDETECT, AURL_ENABLEURL /* | AURL_ENABLEEAURLS */, 0); SendDlgItemMessageW(hDlg, IDC_EVENTTEXTEDIT, EM_AUTOURLDETECT, AURL_ENABLEURL /* | AURL_ENABLEEAURLS */, 0);
/* Note that the RichEdit control never gets themed under WinXP+. One would have to write code to simulate Edit-control theming */ /* Note that the RichEdit control never gets themed under WinXP+; one would have to write code to simulate Edit-control theming */
SendDlgItemMessageW(hDlg, pData->bDisplayWords ? IDC_WORDRADIO : IDC_BYTESRADIO, BM_SETCHECK, BST_CHECKED, 0); SendDlgItemMessageW(hDlg, pData->bDisplayWords ? IDC_WORDRADIO : IDC_BYTESRADIO, BM_SETCHECK, BST_CHECKED, 0);
SendDlgItemMessageW(hDlg, IDC_EVENTDATAEDIT, WM_SETFONT, (WPARAM)pData->hMonospaceFont, (LPARAM)TRUE); SendDlgItemMessageW(hDlg, IDC_EVENTDATAEDIT, WM_SETFONT, (WPARAM)pData->hMonospaceFont, (LPARAM)TRUE);