Add the 'add hardware' option for the maun menu or if the root node is selected

svn path=/trunk/; revision=68343
This commit is contained in:
Ged Murphy 2015-07-04 21:31:19 +00:00
parent b5e1b529b3
commit 8fdb754153
3 changed files with 16 additions and 5 deletions

View 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);

View file

@ -134,7 +134,8 @@ private:
void BuildActionMenuForNode(
_In_ HMENU OwnerMenu,
_In_ CNode *Node
_In_ CNode *Node,
_In_ bool MainMenu
);
HTREEITEM RecurseFindDevice(

View 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