use GET_X/Y_LPARAM as per MSDN
[reactos.git] / reactos / subsys / system / servman / servman.c
index 1e774bc..0d00680 100644 (file)
@@ -4,7 +4,7 @@
  * FILE:        subsys/system/servman/servman.c\r
  * PURPOSE:     Main window message handler\r
  * COPYRIGHT:   Copyright 2005 Ged Murphy <gedmurphy@gmail.com>\r
- *               \r
+ *\r
  */\r
 \r
 #include "servman.h"\r
@@ -16,6 +16,7 @@ HWND hMainWnd;
 HWND hListView;\r
 HWND hStatus;\r
 HWND hTool;\r
+HMENU hShortcutMenu;\r
 \r
 \r
 LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)\r
@@ -33,7 +34,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
             LVCOLUMN lvc = { 0 };\r
 \r
             /* Toolbar buttons */\r
-            TBBUTTON tbb [NUM_BUTTONS] = \r
+            TBBUTTON tbb [NUM_BUTTONS] =\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
@@ -42,9 +43,9 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                 /* Note: First item for a seperator is its width in pixels */\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_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_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
                 {25, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},                             /* separator */\r
@@ -105,7 +106,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 \r
             hListView = CreateWindow(WC_LISTVIEW,\r
                                      NULL,\r
-                                     WS_CHILD | WS_VISIBLE | LVS_REPORT | WS_BORDER | \r
+                                     WS_CHILD | WS_VISIBLE | LVS_REPORT | WS_BORDER |\r
                                      LVS_EDITLABELS | LVS_SORTASCENDING,\r
                                      0, 0, 0, 0, /* sized via WM_SIZE */\r
                                      hwnd,\r
@@ -178,10 +179,17 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                    SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths);\r
 \r
 \r
+/* ======================== Create Popup Menu ============================== */\r
+\r
+            hShortcutMenu = LoadMenu(hInstance, MAKEINTRESOURCE (IDR_POPUP));\r
+            hShortcutMenu = GetSubMenu(hShortcutMenu, 0);\r
+\r
+\r
+\r
+\r
 /* ================= populate the list view with all services =================== */\r
 \r
-                   if (! RefreshServiceList() )\r
-                GetError();\r
+                   RefreshServiceList();\r
 \r
            }\r
            break;\r
@@ -224,16 +232,15 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
            case WM_NOTIFY:\r
         {\r
             LPNMITEMACTIVATE item;\r
+            \r
 \r
             switch (((LPNMHDR) lParam)->code)\r
             {\r
-\r
                    case NM_DBLCLK:\r
-                           item = (LPNMITEMACTIVATE) lParam;\r
-                           PropSheets(hwnd);\r
-\r
+                    item = (LPNMITEMACTIVATE) lParam;\r
+                    PropSheets(hwnd);\r
                            break;\r
-            \r
+\r
                 case TTN_GETDISPINFO:\r
                 {\r
                     LPTOOLTIPTEXT lpttt;\r
@@ -274,7 +281,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                         case ID_RESTART:\r
                             lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_RESTART);\r
                         break;\r
-                        \r
+\r
                         case ID_NEW:\r
                             lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_NEW);\r
                         break;\r
@@ -298,8 +305,8 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
         break;\r
 \r
            case WM_CLOSE:\r
-            /* free the service array */\r
-            FreeMemory();\r
+            FreeMemory(); /* free the service array */\r
+            DestroyMenu(hShortcutMenu);\r
                    DestroyWindow(hwnd);\r
            break;\r
 \r
@@ -307,16 +314,27 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                    PostQuitMessage(0);\r
            break;\r
 \r
+        case WM_CONTEXTMENU:\r
+            {\r
+                int xPos, yPos;\r
+\r
+                xPos = GET_X_LPARAM(lParam); \r
+                yPos = GET_Y_LPARAM(lParam);\r
+\r
+                TrackPopupMenuEx(hShortcutMenu, TPM_RIGHTBUTTON, xPos, yPos, hwnd, NULL);\r
+            }\r
+        break;\r
+\r
            case WM_COMMAND:\r
                    switch(LOWORD(wParam))\r
                    {\r
                 case ID_PROP:\r
                     PropSheets(hwnd);\r
                 break;\r
-                \r
+\r
                 case ID_REFRESH:\r
                     if (! RefreshServiceList() )\r
-                        GetError();\r
+                        GetError(0);\r
 \r
                 case ID_EXPORT:\r
                 break;\r
@@ -340,7 +358,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                 break;\r
 \r
                 case ID_HELP:\r
-                    MessageBox(NULL, _T("Help is not yet implemented\n"), \r
+                    MessageBox(NULL, _T("Help is not yet implemented\n"),\r
                         _T("Note!"), MB_OK | MB_ICONINFORMATION);\r
                 break;\r
 \r
@@ -351,7 +369,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                 case ID_VIEW_CUSTOMIZE:\r
                 break;\r
 \r
-                case ID_HELP_ABOUT:\r
+                case ID_ABOUT:\r
                     DialogBox(hInstance,\r
                               MAKEINTRESOURCE(IDD_ABOUTBOX),\r
                               hwnd,\r