implement list refreshing and program exit
authorGed Murphy <gedmurphy@reactos.org>
Sun, 8 Jan 2006 23:24:43 +0000 (23:24 +0000)
committerGed Murphy <gedmurphy@reactos.org>
Sun, 8 Jan 2006 23:24:43 +0000 (23:24 +0000)
svn path=/trunk/; revision=20741

reactos/subsys/system/servman/En.rc
reactos/subsys/system/servman/query.c
reactos/subsys/system/servman/resource.h
reactos/subsys/system/servman/servman.c

index 6c54d93..da6fd91 100644 (file)
@@ -3,7 +3,7 @@ IDR_MAINMENU MENU
 BEGIN\r
   POPUP "&File"\r
   BEGIN\r
-    MENUITEM "E&xit",ID_FILE_EXIT\r
+    MENUITEM "E&xit",ID_EXIT\r
   END\r
   POPUP "Action"\r
   BEGIN\r
@@ -71,22 +71,22 @@ IDB_BUTTONS BITMAP "res/toolbar.bmp"
 \r
 STRINGTABLE DISCARDABLE\r
 BEGIN\r
-  IDS_FIRSTCOLUMN "Name"\r
+  IDS_FIRSTCOLUMN  "Name"\r
   IDS_SECONDCOLUMN "Description"\r
-  IDS_THIRDCOLUMN "Status"\r
+  IDS_THIRDCOLUMN  "Status"\r
   IDS_FOURTHCOLUMN "Startup Type"\r
-  IDS_FITHCOLUMN "Log On As"\r
+  IDS_FITHCOLUMN   "Log On As"\r
 END\r
 \r
 STRINGTABLE DISCARDABLE\r
 BEGIN\r
   IDS_SERVICES_STATUS_RUNNING "Started"\r
   IDS_SERVICES_STATUS_STOPPED "Stopped"\r
-  IDS_SERVICES_YES "Yes"\r
-  IDS_SERVICES_UNKNOWN "Unknown"\r
-  IDS_SERVICES_AUTO "Automatic"\r
-  IDS_SERVICES_MAN "Manual"\r
-  IDS_SERVICES_DIS "Disabled"\r
+  IDS_SERVICES_YES            "Yes"\r
+  IDS_SERVICES_UNKNOWN        "Unknown"\r
+  IDS_SERVICES_AUTO           "Automatic"\r
+  IDS_SERVICES_MAN            "Manual"\r
+  IDS_SERVICES_DIS            "Disabled"\r
 END\r
 \r
 STRINGTABLE DISCARDABLE\r
index c78582d..1d83b34 100644 (file)
@@ -34,6 +34,8 @@ RefreshServiceList(VOID)
     DWORD Index;\r
     LPCTSTR Path = _T("System\\CurrentControlSet\\Services\\%s");\r
 \r
+    ListView_DeleteAllItems(hListView);\r
+\r
     NumServices = GetServiceList();\r
 \r
     if (NumServices)\r
index ac77ec9..71b3e9a 100644 (file)
@@ -22,7 +22,6 @@
 #define ID_EXIT             2010\r
 \r
 #define IDR_MAINMENU        102\r
-#define ID_FILE_EXIT        4001\r
 #define ID_VIEW_CUSTOMIZE   4021\r
 #define ID_HELP_ABOUT       4031\r
 \r
index 49ffa60..1e30eab 100644 (file)
@@ -26,30 +26,28 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
         {\r
              //HFONT hfDefault;\r
 \r
-            HWND hTool;\r
             TBADDBITMAP tbab;\r
             INT iImageOffset;\r
-            INT statwidths[] = {110, -1};\r
+            INT statwidths[] = {110, -1}; /* widths of status bar */\r
             TCHAR szTemp[256];\r
-            RECT rcClient;\r
             LVCOLUMN lvc = { 0 };\r
 \r
             /* Toolbar buttons */\r
             TBBUTTON tbb [NUM_BUTTONS] = \r
-            { // iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString\r
+            {   /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */\r
                 {TBICON_PROP,    ID_PROP,    TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},    /* properties */\r
                 {TBICON_REFRESH, ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},    /* refresh */\r
                 {TBICON_EXPORT,  ID_EXPORT,  TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},    /* export */\r
 \r
                 /* Note: First item for a seperator is its width in pixels */\r
-                {5, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},                             /* separator */\r
+                {25, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},                             /* separator */\r
 \r
                 {TBICON_START,   ID_START,   TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* start */ \r
                 {TBICON_STOP,    ID_STOP,    TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* stop */\r
                 {TBICON_PAUSE,   ID_PAUSE,   TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* pause */   \r
                 {TBICON_RESTART, ID_RESTART, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* restart */\r
 \r
-                {5, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},                             /* separator */\r
+                {25, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},                             /* separator */\r
 \r
                 {TBICON_NEW,     ID_NEW,   TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* start */\r
                 {TBICON_HELP,    ID_HELP,    TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* stop */\r
@@ -98,10 +96,6 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
             /* Add buttons to toolbar */\r
             SendMessage(hTool, TB_ADDBUTTONS, NUM_BUTTONS, (LPARAM) &tbb);\r
 \r
-            /* Send a WM_SIZE message to layout controls */\r
-            GetClientRect(hwnd, &rcClient);\r
-            SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELONG(rcClient.right, rcClient.bottom));\r
-\r
             /* Show toolbar */\r
             ShowWindow(hTool, SW_SHOWNORMAL);\r
 \r
@@ -121,39 +115,43 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
             if (hListView == NULL)\r
                 MessageBox(hwnd, _T("Could not create List View."), _T("Error"), MB_OK | MB_ICONERROR);\r
 \r
-\r
-\r
             ListView_SetExtendedListViewStyle(hListView, LVS_EX_FULLROWSELECT |\r
-                    /*LVS_EX_GRIDLINES |*/ LVS_EX_HEADERDRAGDROP);\r
+                    LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP);\r
 \r
             lvc.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH  | LVCF_FMT;\r
             lvc.fmt  = LVCFMT_LEFT;\r
 \r
-            /* Add columns to the list-view (first column contains check box). */\r
+            /* Add columns to the list-view */\r
+\r
+            /* name */\r
             lvc.iSubItem = 0;\r
             lvc.cx       = 160;\r
             LoadString(hInstance, IDS_FIRSTCOLUMN, szTemp, 256);\r
             lvc.pszText  = szTemp;\r
             ListView_InsertColumn(hListView, 0, &lvc);\r
 \r
+            /* description */\r
             lvc.iSubItem = 1;\r
             lvc.cx       = 260;\r
             LoadString(hInstance, IDS_SECONDCOLUMN, szTemp, 256);\r
             lvc.pszText  = szTemp;\r
             ListView_InsertColumn(hListView, 1, &lvc);\r
 \r
+            /* status */\r
             lvc.iSubItem = 2;\r
             lvc.cx       = 75;\r
             LoadString(hInstance, IDS_THIRDCOLUMN, szTemp, 256);\r
             lvc.pszText  = szTemp;\r
             ListView_InsertColumn(hListView, 2, &lvc);\r
 \r
+            /* startup type */\r
             lvc.iSubItem = 3;\r
             lvc.cx       = 80;\r
             LoadString(hInstance, IDS_FOURTHCOLUMN, szTemp, 256);\r
             lvc.pszText  = szTemp;\r
             ListView_InsertColumn(hListView, 3, &lvc);\r
 \r
+            /* logon as */\r
             lvc.iSubItem = 4;\r
             lvc.cx       = 100;\r
             LoadString(hInstance, IDS_FITHCOLUMN, szTemp, 256);\r
@@ -309,11 +307,18 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
            case WM_COMMAND:\r
                    switch(LOWORD(wParam))\r
                    {\r
-                           case ID_FILE_EXIT:\r
-                                   PostMessage(hwnd, WM_CLOSE, 0, 0);\r
-                           break;\r
+                case ID_PROP:\r
+                    PropSheets(hwnd);\r
+                break;\r
+                \r
+                case ID_REFRESH:\r
+                    if (! RefreshServiceList() )\r
+                        GetError();\r
+\r
+                case ID_EXPORT:\r
+                break;\r
 \r
-                           case ID_START:\r
+                case ID_START:\r
                            break;\r
 \r
                 case ID_STOP:\r
@@ -328,13 +333,16 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                 case ID_RESTART:\r
                 break;\r
 \r
-                case ID_REFRESH:\r
+                case ID_NEW:\r
                 break;\r
 \r
-                case ID_PROP:\r
-                    PropSheets(hwnd);\r
+                case ID_HELP:\r
                 break;\r
 \r
+                case ID_EXIT:\r
+                                   PostMessage(hwnd, WM_CLOSE, 0, 0);\r
+                           break;\r
+\r
                 case ID_VIEW_CUSTOMIZE:\r
                 break;\r
 \r
@@ -345,9 +353,6 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                               AboutDialogProc);\r
                  break;\r
 \r
-                case ID_EXPORT:\r
-                break;\r
-\r
                    }\r
            break;\r
 \r