From 8fdb754153a57bb8c9e318a75fe91f8be7ffe381 Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Sat, 4 Jul 2015 21:31:19 +0000 Subject: [PATCH] [DEVMGR] 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 | 16 +++++++++++++--- reactos/dll/win32/devmgr/devmgmt/DeviceView.h | 3 ++- reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp b/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp index da3415131bd..a174b3d39cb 100644 --- a/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp +++ b/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp @@ -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); diff --git a/reactos/dll/win32/devmgr/devmgmt/DeviceView.h b/reactos/dll/win32/devmgr/devmgmt/DeviceView.h index 24ab2c20db5..9d5e75704f0 100644 --- a/reactos/dll/win32/devmgr/devmgmt/DeviceView.h +++ b/reactos/dll/win32/devmgr/devmgmt/DeviceView.h @@ -134,7 +134,8 @@ private: void BuildActionMenuForNode( _In_ HMENU OwnerMenu, - _In_ CNode *Node + _In_ CNode *Node, + _In_ bool MainMenu ); HTREEITEM RecurseFindDevice( diff --git a/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp b/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp index f96145b68a7..c4c013c8fd9 100644 --- a/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp +++ b/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp @@ -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 -- 2.17.1