[EVENTVWR] Simplify some duplicated code. (#4745) 4745/head
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 3 Oct 2022 00:26:20 +0000 (02:26 +0200)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 3 Oct 2022 21:17:02 +0000 (23:17 +0200)
base/applications/mscutils/eventvwr/eventvwr.c
base/applications/mscutils/eventvwr/evtdetctl.c

index 1d5328f..a35daff 100644 (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;
 
index ef11ce4..4cc6f97 100644 (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));