bool
CDeviceView::ListDevicesByConnection()
{
- BOOL bSuccess;
+ bool bSuccess;
// Start by adding the root node to the tree
bSuccess = AddRootDevice();
if (bSuccess == false) return false;
// Walk the device tree and add all the devices
- RecurseChildDevices(m_RootDevInst, m_hTreeRoot);
+ (void)RecurseChildDevices(m_RootDevInst, m_hTreeRoot);
// Expand the root item
- (VOID)TreeView_Expand(m_hTreeView,
+ (void)TreeView_Expand(m_hTreeView,
m_hTreeRoot,
TVE_EXPAND);
return true;
}
-VOID
+bool
CDeviceView::RecurseChildDevices(
_In_ DEVINST ParentDevice,
_In_ HTREEITEM hParentTreeItem
)
{
-
HTREEITEM hDevItem = NULL;
DEVINST Device;
- BOOL bSuccess;
+ bool HasProblem = false;
+ bool bSuccess;
// Check if the parent has any child devices
if (GetChildDevice(ParentDevice, &Device) == FALSE)
- return;
+ return true;
// Get the cached device node
CDeviceNode *DeviceNode;
if (DeviceNode == NULL)
{
ATLASSERT(FALSE);
- return;
+ return false;
}
-
- // Check if this is a hidden device
+ // Don't show hidden devices if not requested
if ((m_ShowHidden == TRUE) || (!(DeviceNode->IsHidden())))
{
// Add this device to the tree under its parent
hDevItem = InsertIntoTreeView(hParentTreeItem,
DeviceNode);
-
-
if (hDevItem)
{
// Check if this child has any children itself
- RecurseChildDevices(Device, hDevItem);
+ if (!RecurseChildDevices(Device, hDevItem))
+ HasProblem = true;
+ }
+
+ if (DeviceNode->HasProblem())
+ {
+ HasProblem = true;
}
}
+ // Check for siblings
for (;;)
{
// Check if the parent device has anything at the same level
continue;
}
+ if (DeviceNode->HasProblem())
+ {
+ HasProblem = true;
+ }
+
// Add this device to the tree under its parent
hDevItem = InsertIntoTreeView(hParentTreeItem,
DeviceNode);
if (hDevItem)
{
// Check if this child has any children itself
- RecurseChildDevices(Device, hDevItem);
+ if (!RecurseChildDevices(Device, hDevItem))
+ HasProblem = true;
}
+
}
(void)TreeView_SortChildren(m_hTreeView,
hParentTreeItem,
0);
+ // Expand the class if it has a problem device
+ if (HasProblem == true)
+ {
+ (void)TreeView_Expand(m_hTreeView,
+ hParentTreeItem,
+ TVE_EXPAND);
+ }
+
+ // If there was a problem, expand the ancestors
+ if (HasProblem) return false;
+
+ return true;
}
bool
void
CDeviceView::EmptyLists()
{
- POSITION Pos;
- CNode *Node;
+ CClassNode *ClassNode;
+ CDeviceNode *DeviceNode;
- if (!m_ClassNodeList.IsEmpty())
+ while (!m_ClassNodeList.IsEmpty())
{
- Pos = m_ClassNodeList.GetHeadPosition();
- do
- {
- Node = m_ClassNodeList.GetNext(Pos);
- delete Node;
-
- } while (Pos != NULL);
+ ClassNode = m_ClassNodeList.RemoveTail();
+ delete ClassNode;
}
- if (!m_DeviceNodeList.IsEmpty())
+ while (!m_DeviceNodeList.IsEmpty())
{
- Pos = m_DeviceNodeList.GetHeadPosition();
- do
- {
- Node = m_DeviceNodeList.GetNext(Pos);
- delete Node;
-
- } while (Pos != NULL);
+ DeviceNode = m_DeviceNodeList.RemoveTail();
+ delete DeviceNode;
}
}
break;
}
+ case IDC_ENABLE_DRV:
+ {
+ MessageBox(m_hMainWnd, L"Not yet implemented", L"Enable Driver", MB_OK);
+ break;
+ }
+
+ case IDC_DISABLE_DRV:
+ {
+ MessageBox(m_hMainWnd, L"Not yet implemented", L"Disable Driver", MB_OK);
+ break;
+ }
+
+ case IDC_UPDATE_DRV:
+ {
+ MessageBox(m_hMainWnd, L"Not yet implemented", L"Update Driver", MB_OK);
+ break;
+ }
+
+ case IDC_UNINSTALL_DRV:
+ {
+ MessageBox(m_hMainWnd, L"Not yet implemented", L"Uninstall Driver", MB_OK);
+ break;
+ }
+
+ case IDC_ADD_HARDWARE:
+ {
+ MessageBox(m_hMainWnd, L"Not yet implemented", L"Add Hardware", MB_OK);
+ break;
+ }
+
case IDC_DEVBYTYPE:
{
RefreshView(DevicesByType);
case IDC_SHOWHIDDEN:
{
- UINT CurCheckState, NewCheckState;
-
// Get the current state
- CurCheckState = GetMenuState(m_hMenu, IDC_SHOWHIDDEN, MF_BYCOMMAND);
-
+ UINT CurCheckState = GetMenuState(m_hMenu, IDC_SHOWHIDDEN, MF_BYCOMMAND);
if (CurCheckState == MF_CHECKED)
{
- // Inform the device view of the change
m_DeviceView->SetHiddenDevices(false);
- NewCheckState = MF_UNCHECKED;
+ CheckMenuItem(m_hMenu, IDC_SHOWHIDDEN, MF_BYCOMMAND | MF_UNCHECKED);
}
else if (CurCheckState == MF_UNCHECKED)
{
m_DeviceView->SetHiddenDevices(true);
- NewCheckState = MF_CHECKED;
+ CheckMenuItem(m_hMenu, IDC_SHOWHIDDEN, MF_BYCOMMAND | MF_CHECKED);
}
- else
- {
- ATLASSERT(FALSE);
- break;
- }
-
- // Set the new check state
- CheckMenuItem(m_hMenu, IDC_SHOWHIDDEN, MF_BYCOMMAND | NewCheckState);
-
// Refresh the device view
m_DeviceView->Refresh(m_DeviceView->GetCurrentView(),
false,
// Hand it off to the default message handler
goto HandleDefaultMessage;
}
+ break;
}
case WM_CLOSE:
{
// Destroy the main window
DestroyWindow(hwnd);
+ break;
}
- break;
+
case WM_DESTROY:
{