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
CDeviceView::ShowContextMenu(
_In_ INT xPos,
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();
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;
}
}