[DEVMGMT_NEW]

show popupmenu on right click (not finished yet)

svn path=/trunk/; revision=67979
This commit is contained in:
Christoph von Wittich 2015-05-30 20:32:37 +00:00
parent 54294b0fb1
commit 19d0becca8
3 changed files with 50 additions and 1 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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;
}