From 19d0becca85a451fefa81f74344a3da6977c58e1 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sat, 30 May 2015 20:32:37 +0000 Subject: [PATCH] [DEVMGMT_NEW] show popupmenu on right click (not finished yet) svn path=/trunk/; revision=67979 --- .../mscutils/devmgmt_new/DeviceView.cpp | 40 +++++++++++++++++++ .../mscutils/devmgmt_new/DeviceView.h | 7 +++- .../mscutils/devmgmt_new/MainWindow.cpp | 4 ++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp b/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp index a423fb5c222..c67b7d2a69a 100644 --- a/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp +++ b/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp @@ -53,6 +53,8 @@ CDeviceView::~CDeviceView(void) { delete m_Devices; m_Devices = NULL; + + DestroyMenu(m_hShortcutMenu); } BOOL @@ -64,6 +66,14 @@ CDeviceView::Initialize() bSuccess = m_Devices->Initialize(); if (bSuccess == FALSE) return FALSE; + /* Create Popup Menu */ + m_hShortcutMenu = LoadMenu(g_hInstance, + MAKEINTRESOURCE(IDR_POPUP)); + m_hShortcutMenu = GetSubMenu(m_hShortcutMenu, + 0); + SetMenuDefaultItem(m_hShortcutMenu, IDC_PROP, FALSE); + + /* Create the main treeview */ m_hTreeView = CreateWindowExW(WS_EX_CLIENTEDGE, WC_TREEVIEW, @@ -102,6 +112,36 @@ CDeviceView::Uninitialize() return TRUE; } +VOID +CDeviceView::ShowContextMenu( + _In_ INT xPos, + _In_ INT yPos) +{ + HTREEITEM hSelected; + POINT pt; + RECT rc; + + hSelected = TreeView_GetSelection(m_hTreeView); + + if (TreeView_GetItemRect(m_hTreeView, + hSelected, + &rc, + TRUE)) + { + if (GetCursorPos(&pt) && + ScreenToClient(m_hTreeView, &pt) && + PtInRect(&rc, pt)) + { + TrackPopupMenuEx(m_hShortcutMenu, + TPM_RIGHTBUTTON, + xPos, + yPos, + m_hMainWnd, + NULL); + } + } +} + VOID CDeviceView::Size( _In_ INT x, diff --git a/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h b/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h index 4e8171e1893..72ede93bafe 100644 --- a/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h +++ b/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h @@ -15,7 +15,7 @@ class CDeviceView : public CDevices HWND m_hMainWnd; HWND m_hTreeView; HWND m_hPropertyDialog; - HWND m_hShortcutMenu; + HMENU m_hShortcutMenu; ListDevices m_ListDevices; HIMAGELIST m_ImageList; @@ -34,6 +34,11 @@ public: BOOL Initialize(); BOOL Uninitialize(); + VOID ShowContextMenu( + _In_ INT xPos, + _In_ INT yPos + ); + VOID Size( _In_ INT x, _In_ INT y, diff --git a/reactos/base/applications/mscutils/devmgmt_new/MainWindow.cpp b/reactos/base/applications/mscutils/devmgmt_new/MainWindow.cpp index 0ccd6ea1a35..19942332c7b 100644 --- a/reactos/base/applications/mscutils/devmgmt_new/MainWindow.cpp +++ b/reactos/base/applications/mscutils/devmgmt_new/MainWindow.cpp @@ -449,6 +449,10 @@ CMainWindow::OnNotify(LPARAM lParam) LRESULT CMainWindow::OnContext(LPARAM lParam) { + INT xPos = GET_X_LPARAM(lParam); + INT yPos = GET_Y_LPARAM(lParam); + + m_DeviceView->ShowContextMenu(xPos, yPos); return 0; }