Author: gedmurphy
Date: Wed Jun 17 08:15:08 2015
New Revision: 68167
URL:
http://svn.reactos.org/svn/reactos?rev=68167&view=rev
Log:
[DEVMGR]
- Add the (not yet dynamic) context menu
- Implement right click node select
Modified:
trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp
trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h
trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h
trunk/reactos/dll/win32/devmgr/devmgmt/lang/en-US.rc
Modified: trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/D…
==============================================================================
--- trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp [iso-8859-1] Wed Jun 17 08:15:08
2015
@@ -34,7 +34,7 @@
{
CDeviceView *This;
BOOL ScanForChanges;
- BOOL UpdateView;
+BOOL UpdateView;
};
@@ -46,7 +46,8 @@
m_hMainWnd(hMainWnd),
m_hTreeView(NULL),
m_hPropertyDialog(NULL),
- m_hShortcutMenu(NULL),
+ m_hMenu(NULL),
+ m_hContextMenu(NULL),
m_ViewType(DevicesByType),
m_ShowHidden(FALSE),
m_RootClassImage(-1),
@@ -72,7 +73,7 @@
WC_TREEVIEW,
NULL,
WS_CHILD | WS_VISIBLE | WS_BORDER | TVS_HASLINES |
- TVS_HASBUTTONS | TVS_SHOWSELALWAYS | TVS_LINESATROOT,
+ TVS_HASBUTTONS | TVS_SHOWSELALWAYS | TVS_LINESATROOT,
0, 0, 0, 0,
m_hMainWnd,
(HMENU)IDC_TREEVIEW,
@@ -89,6 +90,11 @@
SetWindowTheme(m_hTreeView, L"explorer", NULL);
}
+ // Create the context menu and make properties the default item
+ m_hMenu = LoadMenuW(g_hInstance, MAKEINTRESOURCEW(IDR_POPUP));
+ m_hContextMenu = GetSubMenu(m_hMenu, 0);
+ SetMenuDefaultItem(m_hContextMenu, IDC_PROPERTIES, FALSE);
+
return !!(m_hTreeView);
}
@@ -103,11 +109,13 @@
ZeroMemory(&m_ImageListData, sizeof(SP_CLASSIMAGELIST_DATA));
}
+ DestroyMenu(m_hMenu);
+
return true;
}
-void
-CDeviceView::Size(
+LRESULT
+CDeviceView::OnSize(
_In_ int x,
_In_ int y,
_In_ int cx,
@@ -122,12 +130,64 @@
cx,
cy,
SWP_NOZORDER);
-}
+
+ return 0;
+}
+
+LRESULT
+CDeviceView::OnRightClick(
+ _In_ LPNMHDR NmHdr
+ )
+{
+ HTREEITEM hItem = TreeView_GetNextItem(NmHdr->hwndFrom, 0, TVGN_DROPHILITE);
+ if (hItem)
+ {
+ TreeView_SelectItem(NmHdr->hwndFrom, hItem);
+ }
+
+ return 0;
+}
+
+LRESULT
+CDeviceView::OnContextMenu(
+ _In_ LPARAM lParam
+ )
+{
+ HTREEITEM hSelected = TreeView_GetSelection(m_hTreeView);
+
+ RECT rc;
+ if (TreeView_GetItemRect(m_hTreeView,
+ hSelected,
+ &rc,
+ TRUE))
+ {
+ POINT pt;
+ if (GetCursorPos(&pt) &&
+ ScreenToClient(m_hTreeView, &pt) &&
+ PtInRect(&rc, pt))
+ {
+ INT xPos = GET_X_LPARAM(lParam);
+ INT yPos = GET_Y_LPARAM(lParam);
+
+ TrackPopupMenuEx(m_hContextMenu,
+ TPM_RIGHTBUTTON,
+ xPos,
+ yPos,
+ m_hMainWnd,
+ NULL);
+ }
+ }
+
+ return 0;
+}
+
void
-CDeviceView::Refresh(_In_ ViewType Type,
- _In_ bool ScanForChanges,
- _In_ bool UpdateView)
+CDeviceView::Refresh(
+ _In_ ViewType Type,
+ _In_ bool ScanForChanges,
+ _In_ bool UpdateView
+ )
{
// Enum devices on a seperate thread to keep the gui responsive
@@ -192,7 +252,9 @@
}
bool
-CDeviceView::HasProperties(_In_ LPTV_ITEMW TvItem)
+CDeviceView::HasProperties(
+ _In_ LPTV_ITEMW TvItem
+ )
{
CNode *Node = GetNode(TvItem);
if (Node)
@@ -203,7 +265,9 @@
}
bool
-CDeviceView::IsDisabled(_In_ LPTV_ITEMW TvItem)
+CDeviceView::IsDisabled(
+ _In_ LPTV_ITEMW TvItem
+ )
{
CNode *Node = GetNode(TvItem);
if (Node)
@@ -214,7 +278,9 @@
}
bool
-CDeviceView::CanDisable(_In_ LPTV_ITEMW TvItem)
+CDeviceView::CanDisable(
+ _In_ LPTV_ITEMW TvItem
+ )
{
CNode *Node = GetNode(TvItem);
if (Node)
Modified: trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/D…
==============================================================================
--- trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h [iso-8859-1] Wed Jun 17 08:15:08
2015
@@ -20,7 +20,8 @@
HWND m_hMainWnd;
HWND m_hTreeView;
HWND m_hPropertyDialog;
- HWND m_hShortcutMenu;
+ HMENU m_hMenu;
+ HMENU m_hContextMenu;
ViewType m_ViewType;
HTREEITEM m_hTreeRoot;
@@ -39,11 +40,19 @@
bool Initialize();
bool Uninitialize();
- VOID Size(
+ LRESULT OnSize(
_In_ int x,
_In_ int y,
_In_ int cx,
_In_ int cy
+ );
+
+ LRESULT OnRightClick(
+ _In_ LPNMHDR NmHdr
+ );
+
+ LRESULT OnContextMenu(
+ _In_ LPARAM lParam
);
VOID Refresh(
@@ -55,12 +64,7 @@
VOID DisplayPropertySheet();
VOID SetFocus();
- //VOID SetDeviceListType(ListDevices List)
- //{
- // m_ListDevices = List;
- //}
-
- VOID ShowHiddenDevices(_In_ bool ShowHidden)
+ VOID SetHiddenDevices(_In_ bool ShowHidden)
{
m_ShowHidden = ShowHidden;
}
Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/M…
==============================================================================
--- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp [iso-8859-1] Wed Jun 17 08:15:08
2015
@@ -16,7 +16,6 @@
#define BTN_PROPERTIES 0
#define BTN_SCAN_HARDWARE 1
-#define BTN_SEPERATOR -1
#define BTN_ENABLE_DRV 2
#define BTN_DISABLE_DRV 3
#define BTN_UPDATE_DRV 4
@@ -124,7 +123,7 @@
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN |
WS_CLIPSIBLINGS,
CW_USEDEFAULT,
CW_USEDEFAULT,
- 500,
+ 550,
500,
NULL,
NULL,
@@ -229,9 +228,6 @@
true);
return true;
}
-
-
-
bool
CMainWindow::CreateToolBar()
@@ -311,7 +307,7 @@
return bRet;
}
-void CMainWindow::UpdateContext(_In_ LPTV_ITEMW TvItem)
+void CMainWindow::UpdateUiContext(_In_ LPTV_ITEMW TvItem)
{
WORD State;
@@ -437,10 +433,10 @@
lvHeight = rcClient.bottom - iToolHeight - iStatusHeight;
// Resize the device view
- m_DeviceView->Size(0,
- iToolHeight,
- rcClient.right,
- lvHeight);
+ m_DeviceView->OnSize(0,
+ iToolHeight,
+ rcClient.right,
+ lvHeight);
return 0;
}
@@ -449,27 +445,20 @@
CMainWindow::OnNotify(LPARAM lParam)
{
LPNMHDR NmHdr = (LPNMHDR)lParam;
+ LRESULT Ret;
switch (NmHdr->code)
{
case TVN_SELCHANGED:
{
LPNMTREEVIEW NmTreeView = (LPNMTREEVIEW)lParam;
- UpdateContext(&NmTreeView->itemNew);
- break;
- }
-
- case TVN_DELETEITEMW:
- {
- LPNMTREEVIEW NmTreeView = (LPNMTREEVIEW)lParam;
- NmTreeView->action = NmTreeView->action;
-
- break;
- }
-
- case NM_DBLCLK:
- {
- m_DeviceView->DisplayPropertySheet();
+ UpdateUiContext(&NmTreeView->itemNew);
+ break;
+ }
+
+ case NM_RCLICK:
+ {
+ Ret = m_DeviceView->OnRightClick(NmHdr);
break;
}
@@ -486,7 +475,7 @@
LRESULT
CMainWindow::OnContext(LPARAM lParam)
{
- return 0;
+ return m_DeviceView->OnContextMenu(lParam);
}
LRESULT
@@ -535,12 +524,12 @@
if (CurCheckState == MF_CHECKED)
{
// Inform the device view of the change
- m_DeviceView->ShowHiddenDevices(false);
+ m_DeviceView->SetHiddenDevices(false);
NewCheckState = MF_UNCHECKED;
}
else if (CurCheckState == MF_UNCHECKED)
{
- m_DeviceView->ShowHiddenDevices(true);
+ m_DeviceView->SetHiddenDevices(true);
NewCheckState = MF_CHECKED;
}
else
Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/M…
==============================================================================
--- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h [iso-8859-1] Wed Jun 17 08:15:08
2015
@@ -44,7 +44,7 @@
bool CreateToolBar();
bool CreateStatusBar();
- void UpdateContext(_In_ LPTV_ITEMW TvItem);
+ void UpdateUiContext(_In_ LPTV_ITEMW TvItem);
bool StatusBarLoadString(
HWND hStatusBar,
Modified: trunk/reactos/dll/win32/devmgr/devmgmt/lang/en-US.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/l…
==============================================================================
--- trunk/reactos/dll/win32/devmgr/devmgmt/lang/en-US.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr/devmgmt/lang/en-US.rc [iso-8859-1] Wed Jun 17 08:15:08
2015
@@ -9,6 +9,7 @@
POPUP "Action"
BEGIN
MENUITEM "Update driver software..." IDC_UPDATE_DRV
+ MENUITEM "Enable" IDC_ENABLE_DRV
MENUITEM "Disable" IDC_DISABLE_DRV
MENUITEM "Uninstall" IDC_UNINSTALL_DRV
MENUITEM SEPARATOR
@@ -36,7 +37,15 @@
BEGIN
POPUP "popup"
BEGIN
- MENUITEM "Properties", IDC_PROPERTIES, GRAYED
+ MENUITEM "Update driver software..." IDC_UPDATE_DRV
+ MENUITEM "Enable" IDC_ENABLE_DRV
+ MENUITEM "Disable" IDC_DISABLE_DRV
+ MENUITEM "Uninstall" IDC_UNINSTALL_DRV
+ MENUITEM SEPARATOR
+ MENUITEM "Scan for hardware changes" IDC_SCAN_HARDWARE
+ MENUITEM "Add hardware" IDC_ADD_HARDWARE, GRAYED
+ MENUITEM SEPARATOR
+ MENUITEM "Properties", IDC_PROPERTIES
END
END