[DEVMGR]
authorGed Murphy <gedmurphy@reactos.org>
Sat, 4 Jul 2015 21:31:19 +0000 (21:31 +0000)
committerGed Murphy <gedmurphy@reactos.org>
Sat, 4 Jul 2015 21:31:19 +0000 (21:31 +0000)
Add the 'add hardware' option for the maun menu or if the root node is selected

svn path=/trunk/; revision=68343

reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp
reactos/dll/win32/devmgr/devmgmt/DeviceView.h
reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp

index da34151..a174b3d 100644 (file)
@@ -168,7 +168,7 @@ CDeviceView::OnContextMenu(
                 HMENU hContextMenu = CreatePopupMenu();
 
                 // Add the actions for this node
-                BuildActionMenuForNode(hContextMenu, Node);
+                BuildActionMenuForNode(hContextMenu, Node, false);
 
                 INT xPos = GET_X_LPARAM(lParam);
                 INT yPos = GET_Y_LPARAM(lParam);
@@ -279,7 +279,7 @@ CDeviceView::CreateActionMenu(
     CNode *Node = GetSelectedNode();
     if (Node)
     {
-        BuildActionMenuForNode(OwnerMenu, Node);
+        BuildActionMenuForNode(OwnerMenu, Node, MainMenu);
         return true;
     }
 
@@ -774,7 +774,8 @@ CDeviceView::InsertIntoTreeView(
 void
 CDeviceView::BuildActionMenuForNode(
     _In_ HMENU OwnerMenu,
-    _In_ CNode *Node
+    _In_ CNode *Node,
+    _In_ bool MainMenu
     )
 {
     // Create a seperator structure 
@@ -843,6 +844,15 @@ CDeviceView::BuildActionMenuForNode(
     InsertMenuItemW(OwnerMenu, i, TRUE, &MenuItemInfo);
     i++;
 
+    if ((Node->GetNodeType() == RootNode) || (MainMenu == true))
+    {
+        String.LoadStringW(g_hInstance, IDS_MENU_ADD);
+        MenuItemInfo.wID = IDC_ADD_HARDWARE;
+        MenuItemInfo.dwTypeData = String.GetBuffer();
+        InsertMenuItemW(OwnerMenu, i, TRUE, &MenuItemInfo);
+        i++;
+    }
+
     if (Node->HasProperties())
     {
         InsertMenuItemW(OwnerMenu, i, TRUE, &MenuSeperator);
index 24ab2c2..9d5e757 100644 (file)
@@ -134,7 +134,8 @@ private:
 
     void BuildActionMenuForNode(
         _In_ HMENU OwnerMenu,
-        _In_ CNode *Node
+        _In_ CNode *Node,
+        _In_ bool MainMenu
         );
 
     HTREEITEM RecurseFindDevice(
index f96145b..c4c013c 100644 (file)
@@ -596,9 +596,9 @@ CMainWindow::OnCommand(WPARAM wParam,
             HMENU hMenu = CreatePopupMenu();
             m_DeviceView->CreateActionMenu(hMenu, true);
 
+            // Calculate where to put the menu
             RECT rc;
             GetMenuItemRect(m_hMainWnd, m_hMenu, 1, &rc);
-
             LONG Height = rc.bottom - rc.top;
 
             // Display the menu