mirror of
https://github.com/reactos/reactos.git
synced 2025-06-05 09:20:30 +00:00
[DEVMGR]
- Automatically refresh the view whenever there is a hardware change on the machine - Don't force a refresh when we enable/disable devices, this is now be picked up automatically svn path=/trunk/; revision=69649
This commit is contained in:
parent
ac1ef8ea3b
commit
6ed09fb64b
4 changed files with 44 additions and 8 deletions
|
@ -700,13 +700,7 @@ CDeviceView::EnableSelectedDevice(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Node->EnableDevice(Enable, NeedsReboot))
|
return Node->EnableDevice(Enable, NeedsReboot);
|
||||||
{
|
|
||||||
Refresh(m_ViewType, true, true, Node->GetDeviceId());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#define BTN_UPDATE_DRV 4
|
#define BTN_UPDATE_DRV 4
|
||||||
#define BTN_UNINSTALL_DRV 5
|
#define BTN_UNINSTALL_DRV 5
|
||||||
|
|
||||||
|
#define REFRESH_TIMER 1
|
||||||
|
|
||||||
HINSTANCE g_hThisInstance = NULL;
|
HINSTANCE g_hThisInstance = NULL;
|
||||||
HINSTANCE g_hParentInstance = NULL;
|
HINSTANCE g_hParentInstance = NULL;
|
||||||
|
|
||||||
|
@ -81,7 +83,8 @@ CDeviceManager::CDeviceManager(void) :
|
||||||
m_hMainWnd(NULL),
|
m_hMainWnd(NULL),
|
||||||
m_hStatusBar(NULL),
|
m_hStatusBar(NULL),
|
||||||
m_hToolBar(NULL),
|
m_hToolBar(NULL),
|
||||||
m_CmdShow(0)
|
m_CmdShow(0),
|
||||||
|
m_RefreshPending(false)
|
||||||
{
|
{
|
||||||
m_szMainWndClass = L"DevMgmtWndClass";
|
m_szMainWndClass = L"DevMgmtWndClass";
|
||||||
}
|
}
|
||||||
|
@ -773,6 +776,42 @@ CDeviceManager::MainWndProc(_In_ HWND hwnd,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WM_DEVICECHANGE:
|
||||||
|
{
|
||||||
|
if (wParam == DBT_DEVNODES_CHANGED)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// The OS can send multiple change messages in quick sucsession. 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)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
// Cleanup the timer
|
||||||
|
KillTimer(hwnd, REFRESH_TIMER);
|
||||||
|
|
||||||
|
// Allow more change notifications
|
||||||
|
InterlockedExchange((LONG *)&This->m_RefreshPending, false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_ENTERMENULOOP:
|
case WM_ENTERMENULOOP:
|
||||||
{
|
{
|
||||||
This->UpdateStatusBar(true);
|
This->UpdateStatusBar(true);
|
||||||
|
|
|
@ -17,6 +17,7 @@ class CDeviceManager
|
||||||
HMENU m_hMenu;
|
HMENU m_hMenu;
|
||||||
HMENU m_hActionMenu;
|
HMENU m_hActionMenu;
|
||||||
int m_CmdShow;
|
int m_CmdShow;
|
||||||
|
bool m_RefreshPending;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CDeviceManager(void);
|
CDeviceManager(void);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <Cfgmgr32.h>
|
#include <Cfgmgr32.h>
|
||||||
#include <devguid.h>
|
#include <devguid.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
|
#include <dbt.h>
|
||||||
#include <RegStr.h>
|
#include <RegStr.h>
|
||||||
|
|
||||||
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
|
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
|
||||||
|
@ -59,6 +60,7 @@ OUT LPDWORD lpReboot);
|
||||||
#include <strsafe.h>
|
#include <strsafe.h>
|
||||||
#include <regstr.h>
|
#include <regstr.h>
|
||||||
#include <newdevp.h>
|
#include <newdevp.h>
|
||||||
|
#include <dbt.h>
|
||||||
|
|
||||||
#include <setupapi.h>
|
#include <setupapi.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
|
Loading…
Reference in a new issue