{
}
-
bool
CDeviceManager::Create(_In_ HWND /*hWndParent*/,
_In_ HINSTANCE hInst,
}
-
/* PRIVATE METHODS **********************************************/
bool
}
bool
-CDeviceManager::RefreshView(_In_ ViewType Type)
+CDeviceManager::RefreshView(_In_ ViewType Type,
+ _In_ bool ScanForChanges)
{
UINT CheckId = 0;
// Refreshed the cached view
- m_DeviceView->Refresh(Type, FALSE, TRUE, NULL);
+ m_DeviceView->Refresh(Type, ScanForChanges, true);
// Get the menu item id
switch (Type)
{
- case DevicesByType: CheckId = IDC_DEVBYTYPE; break;
- case DevicesByConnection: CheckId = IDC_DEVBYCONN; break;
- case ResourcesByType: CheckId = IDC_RESBYTYPE; break;
- case ResourcesByConnection: CheckId = IDC_RESBYCONN; break;
- default: ATLASSERT(FALSE); break;
+ case DevicesByType:
+ CheckId = IDC_DEVBYTYPE;
+ break;
+
+ case DevicesByConnection:
+ CheckId = IDC_DEVBYCONN;
+ break;
+
+ case ResourcesByType:
+ CheckId = IDC_RESBYTYPE;
+ break;
+
+ case ResourcesByConnection:
+ CheckId = IDC_RESBYCONN;
+ break;
+
+ default:
+ ATLASSERT(FALSE);
+ break;
}
// Set the new check item
(HMENU)IDC_TOOLBAR,
g_hThisInstance,
NULL);
- if (m_hToolBar == NULL) return FALSE;
+ if (m_hToolBar == NULL)
+ return FALSE;
// Don't show clipped buttons
SendMessageW(m_hToolBar,
SendMessageW(m_hToolBar, TB_SETSTATE, IDC_DISABLE_DRV, MAKELPARAM(State, 0));
}
-
-
bool
CDeviceManager::StatusBarLoadString(_In_ HWND hStatusBar,
_In_ INT PartId,
if (m_DeviceView->Initialize())
{
// Do the initial scan
- m_DeviceView->Refresh(m_DeviceView->GetCurrentView(),
- true,
- true,
- NULL);
+ RefreshView(m_DeviceView->GetCurrentView(), true);
// Display the window according to the user request
ShowWindow(hwnd, m_CmdShow);
lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_UNINSTALL);
break;
}
- idButton = idButton;
break;
}
}
case IDC_DEVBYTYPE:
{
- RefreshView(DevicesByType);
+ RefreshView(DevicesByType, false);
break;
}
case IDC_DEVBYCONN:
{
- RefreshView(DevicesByConnection);
+ RefreshView(DevicesByConnection, false);
break;
}
CheckMenuItem(m_hMenu, IDC_SHOWHIDDEN, MF_BYCOMMAND | MF_CHECKED);
}
// Refresh the device view
- m_DeviceView->Refresh(m_DeviceView->GetCurrentView(),
- false,
- true,
- NULL);
+ RefreshView(m_DeviceView->GetCurrentView(), false);
break;
}
return RetCode;
}
+void
+CDeviceManager::OnActivate(void)
+{
+ m_DeviceView->SetFocus();
+}
+
LRESULT
CDeviceManager::OnDestroy(void)
{
if (wParam == DBT_DEVNODES_CHANGED)
{
//
- // The OS can send multiple change messages in quick sucsession. To avoid
+ // The OS can send multiple change messages in quick succession. To avoid
// refreshing multiple times (and to avoid waiting in the message thread)
// we set a timer to run in 500ms, which should leave enough time for all
// the messages to come through. Wrap so we don't set multiple timers
//
- if (InterlockedCompareExchange((LONG *)&This->m_RefreshPending, true, false) == false)
+ if (InterlockedCompareExchange((LONG *)&This->m_RefreshPending, TRUE, FALSE) == FALSE)
{
SetTimer(hwnd, REFRESH_TIMER, 500, NULL);
}
}
break;
}
+
case WM_TIMER:
{
if (wParam == REFRESH_TIMER)
{
// Schedule a refresh (this just creates a thread and returns)
- This->m_DeviceView->Refresh(This->m_DeviceView->GetCurrentView(),
- true,
- true,
- NULL);
+ This->RefreshView(This->m_DeviceView->GetCurrentView(), true);
// Cleanup the timer
KillTimer(hwnd, REFRESH_TIMER);
// Allow more change notifications
- InterlockedExchange((LONG *)&This->m_RefreshPending, false);
+ InterlockedExchange((LONG *)&This->m_RefreshPending, FALSE);
}
break;
}
DestroyWindow(hwnd);
break;
}
-
+
+ case WM_ACTIVATE:
+ {
+ if (LOWORD(hwnd))
+ This->OnActivate();
+ break;
+ }
case WM_DESTROY:
{