- In 'Devices by Connection, if a device has a problem, expand the treeview to to show that problem device.
- Add a missing break in WM_COMMAND to stop the app from closing
- Fix clearing the lists

svn path=/trunk/; revision=68182
This commit is contained in:
Ged Murphy 2015-06-18 10:26:30 +00:00
parent 38dbc4f271
commit f36c37f8d9
3 changed files with 82 additions and 50 deletions

View file

@ -570,37 +570,37 @@ CDeviceView::ListDevicesByType()
bool bool
CDeviceView::ListDevicesByConnection() CDeviceView::ListDevicesByConnection()
{ {
BOOL bSuccess; bool bSuccess;
// Start by adding the root node to the tree // Start by adding the root node to the tree
bSuccess = AddRootDevice(); bSuccess = AddRootDevice();
if (bSuccess == false) return false; if (bSuccess == false) return false;
// Walk the device tree and add all the devices // Walk the device tree and add all the devices
RecurseChildDevices(m_RootDevInst, m_hTreeRoot); (void)RecurseChildDevices(m_RootDevInst, m_hTreeRoot);
// Expand the root item // Expand the root item
(VOID)TreeView_Expand(m_hTreeView, (void)TreeView_Expand(m_hTreeView,
m_hTreeRoot, m_hTreeRoot,
TVE_EXPAND); TVE_EXPAND);
return true; return true;
} }
VOID bool
CDeviceView::RecurseChildDevices( CDeviceView::RecurseChildDevices(
_In_ DEVINST ParentDevice, _In_ DEVINST ParentDevice,
_In_ HTREEITEM hParentTreeItem _In_ HTREEITEM hParentTreeItem
) )
{ {
HTREEITEM hDevItem = NULL; HTREEITEM hDevItem = NULL;
DEVINST Device; DEVINST Device;
BOOL bSuccess; bool HasProblem = false;
bool bSuccess;
// Check if the parent has any child devices // Check if the parent has any child devices
if (GetChildDevice(ParentDevice, &Device) == FALSE) if (GetChildDevice(ParentDevice, &Device) == FALSE)
return; return true;
// Get the cached device node // Get the cached device node
CDeviceNode *DeviceNode; CDeviceNode *DeviceNode;
@ -608,26 +608,30 @@ CDeviceView::RecurseChildDevices(
if (DeviceNode == NULL) if (DeviceNode == NULL)
{ {
ATLASSERT(FALSE); ATLASSERT(FALSE);
return; return false;
} }
// Don't show hidden devices if not requested
// Check if this is a hidden device
if ((m_ShowHidden == TRUE) || (!(DeviceNode->IsHidden()))) if ((m_ShowHidden == TRUE) || (!(DeviceNode->IsHidden())))
{ {
// Add this device to the tree under its parent // Add this device to the tree under its parent
hDevItem = InsertIntoTreeView(hParentTreeItem, hDevItem = InsertIntoTreeView(hParentTreeItem,
DeviceNode); DeviceNode);
if (hDevItem) if (hDevItem)
{ {
// Check if this child has any children itself // 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 (;;) for (;;)
{ {
// Check if the parent device has anything at the same level // Check if the parent device has anything at the same level
@ -647,20 +651,39 @@ CDeviceView::RecurseChildDevices(
continue; continue;
} }
if (DeviceNode->HasProblem())
{
HasProblem = true;
}
// Add this device to the tree under its parent // Add this device to the tree under its parent
hDevItem = InsertIntoTreeView(hParentTreeItem, hDevItem = InsertIntoTreeView(hParentTreeItem,
DeviceNode); DeviceNode);
if (hDevItem) if (hDevItem)
{ {
// Check if this child has any children itself // Check if this child has any children itself
RecurseChildDevices(Device, hDevItem); if (!RecurseChildDevices(Device, hDevItem))
HasProblem = true;
} }
} }
(void)TreeView_SortChildren(m_hTreeView, (void)TreeView_SortChildren(m_hTreeView,
hParentTreeItem, hParentTreeItem,
0); 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 bool
@ -860,29 +883,19 @@ CNode* CDeviceView::GetSelectedNode()
void void
CDeviceView::EmptyLists() CDeviceView::EmptyLists()
{ {
POSITION Pos; CClassNode *ClassNode;
CNode *Node; CDeviceNode *DeviceNode;
if (!m_ClassNodeList.IsEmpty()) while (!m_ClassNodeList.IsEmpty())
{ {
Pos = m_ClassNodeList.GetHeadPosition(); ClassNode = m_ClassNodeList.RemoveTail();
do delete ClassNode;
{
Node = m_ClassNodeList.GetNext(Pos);
delete Node;
} while (Pos != NULL);
} }
if (!m_DeviceNodeList.IsEmpty()) while (!m_DeviceNodeList.IsEmpty())
{ {
Pos = m_DeviceNodeList.GetHeadPosition(); DeviceNode = m_DeviceNodeList.RemoveTail();
do delete DeviceNode;
{
Node = m_DeviceNodeList.GetNext(Pos);
delete Node;
} while (Pos != NULL);
} }
} }

View file

@ -99,7 +99,7 @@ private:
_Out_ HDEVINFO *hDevInfo _Out_ HDEVINFO *hDevInfo
); );
VOID RecurseChildDevices( bool RecurseChildDevices(
_In_ DEVINST ParentDevice, _In_ DEVINST ParentDevice,
_In_ HTREEITEM hParentTreeItem _In_ HTREEITEM hParentTreeItem
); );

View file

@ -509,6 +509,36 @@ CMainWindow::OnCommand(WPARAM wParam,
break; 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: case IDC_DEVBYTYPE:
{ {
RefreshView(DevicesByType); RefreshView(DevicesByType);
@ -523,31 +553,18 @@ CMainWindow::OnCommand(WPARAM wParam,
case IDC_SHOWHIDDEN: case IDC_SHOWHIDDEN:
{ {
UINT CurCheckState, NewCheckState;
// Get the current state // 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) if (CurCheckState == MF_CHECKED)
{ {
// Inform the device view of the change
m_DeviceView->SetHiddenDevices(false); m_DeviceView->SetHiddenDevices(false);
NewCheckState = MF_UNCHECKED; CheckMenuItem(m_hMenu, IDC_SHOWHIDDEN, MF_BYCOMMAND | MF_UNCHECKED);
} }
else if (CurCheckState == MF_UNCHECKED) else if (CurCheckState == MF_UNCHECKED)
{ {
m_DeviceView->SetHiddenDevices(true); 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 // Refresh the device view
m_DeviceView->Refresh(m_DeviceView->GetCurrentView(), m_DeviceView->Refresh(m_DeviceView->GetCurrentView(),
false, false,
@ -688,14 +705,16 @@ CMainWindow::MainWndProc(HWND hwnd,
// Hand it off to the default message handler // Hand it off to the default message handler
goto HandleDefaultMessage; goto HandleDefaultMessage;
} }
break;
} }
case WM_CLOSE: case WM_CLOSE:
{ {
// Destroy the main window // Destroy the main window
DestroyWindow(hwnd); DestroyWindow(hwnd);
break;
} }
break;
case WM_DESTROY: case WM_DESTROY:
{ {