Author: cwittich
Date: Sun May 31 09:14:29 2015
New Revision: 67981
URL:
http://svn.reactos.org/svn/reactos?rev=67981&view=rev
Log:
[DEVMGMT_NEW]
enable/disable context menu items on selection change
Modified:
trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp
trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h
trunk/reactos/base/applications/mscutils/devmgmt_new/MainWindow.cpp
Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp [iso-8859-1]
(original)
+++ trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp [iso-8859-1] Sun
May 31 09:14:29 2015
@@ -110,6 +110,30 @@
(VOID)m_Devices->Uninitialize();
return TRUE;
+}
+
+BOOL CDeviceView::HasChildItem(
+ _In_ HTREEITEM Item)
+{
+ return (TreeView_GetChild(m_hTreeView, Item) != NULL);
+}
+
+BOOL CDeviceView::IsRootItem(
+ _In_ HTREEITEM Item)
+{
+ return (TreeView_GetRoot(m_hTreeView) == Item);
+}
+
+BOOL CDeviceView::IsRootItemSelected()
+{
+ return (TreeView_GetRoot(m_hTreeView) == TreeView_GetSelection(m_hTreeView));
+}
+
+VOID CDeviceView::EnableContextMenuItem(
+ _In_ UINT Id,
+ _In_ UINT Enabled)
+{
+ EnableMenuItem(m_hShortcutMenu, Id, Enabled);
}
VOID
Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h [iso-8859-1]
(original)
+++ trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h [iso-8859-1] Sun May
31 09:14:29 2015
@@ -34,6 +34,11 @@
BOOL Initialize();
BOOL Uninitialize();
+ VOID EnableContextMenuItem(
+ _In_ UINT Id,
+ _In_ UINT Enabled
+ );
+
VOID ShowContextMenu(
_In_ INT xPos,
_In_ INT yPos
@@ -49,12 +54,27 @@
VOID Refresh();
VOID DisplayPropertySheet();
VOID SetFocus();
-
+
+ BOOL IsRootItemSelected();
+
+ BOOL IsRootItem(
+ _In_ HTREEITEM Item
+ );
+
+ BOOL HasChildItem(
+ _In_ HTREEITEM Item
+ );
+
VOID SetDeviceListType(ListDevices List)
{
m_ListDevices = List;
}
+ ListDevices GetDeviceListType()
+ {
+ return m_ListDevices;
+ }
+
VOID ShowHiddenDevices(_In_ BOOL ShowHidden)
{
m_ShowHidden = ShowHidden;
Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/MainWindow.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/devmgmt_new/MainWindow.cpp [iso-8859-1]
(original)
+++ trunk/reactos/base/applications/mscutils/devmgmt_new/MainWindow.cpp [iso-8859-1] Sun
May 31 09:14:29 2015
@@ -429,7 +429,61 @@
break;
}
-
+
+ case TVN_SELCHANGED:
+ {
+ LPNM_TREEVIEW pnmtv = (LPNM_TREEVIEW)lParam;
+ ListDevices ListType = m_DeviceView->GetDeviceListType();
+
+ if (ListType == DevicesByType)
+ {
+ if (!m_DeviceView->HasChildItem(pnmtv->itemNew.hItem))
+ {
+ SendMessage(m_hToolBar,
+ TB_SETSTATE,
+ IDC_PROP,
+ (LPARAM)MAKELONG(TBSTATE_ENABLED, 0));
+
+ EnableMenuItem(GetMenu(m_hMainWnd), IDC_PROP, MF_ENABLED);
+ m_DeviceView->EnableContextMenuItem(IDC_PROP, MF_ENABLED);
+ }
+ else
+ {
+ SendMessage(m_hToolBar,
+ TB_SETSTATE,
+ IDC_PROP,
+ (LPARAM)MAKELONG(TBSTATE_INDETERMINATE, 0));
+
+ EnableMenuItem(GetMenu(m_hMainWnd), IDC_PROP, MF_GRAYED);
+ m_DeviceView->EnableContextMenuItem(IDC_PROP, MF_GRAYED);
+ }
+ }
+ else if (ListType == DevicesByConnection)
+ {
+ if (m_DeviceView->IsRootItem(pnmtv->itemNew.hItem))
+ {
+ SendMessage(m_hToolBar,
+ TB_SETSTATE,
+ IDC_PROP,
+ (LPARAM)MAKELONG(TBSTATE_INDETERMINATE, 0));
+
+ EnableMenuItem(GetMenu(m_hMainWnd), IDC_PROP, MF_GRAYED);
+ m_DeviceView->EnableContextMenuItem(IDC_PROP, MF_GRAYED);
+ }
+ else
+ {
+ SendMessage(m_hToolBar,
+ TB_SETSTATE,
+ IDC_PROP,
+ (LPARAM)MAKELONG(TBSTATE_ENABLED, 0));
+
+ EnableMenuItem(GetMenu(m_hMainWnd), IDC_PROP, MF_ENABLED);
+ m_DeviceView->EnableContextMenuItem(IDC_PROP, MF_ENABLED);
+ }
+ }
+ }
+ break;
+
case NM_DBLCLK:
{
m_DeviceView->DisplayPropertySheet();
@@ -438,7 +492,18 @@
case NM_RETURN:
{
- m_DeviceView->DisplayPropertySheet();
+ ListDevices ListType = m_DeviceView->GetDeviceListType();
+ if (ListType == DevicesByType)
+ {
+ m_DeviceView->DisplayPropertySheet();
+ }
+ else if (ListType == DevicesByConnection)
+ {
+ if (!m_DeviceView->IsRootItemSelected())
+ {
+ m_DeviceView->DisplayPropertySheet();
+ }
+ }
break;
}
}