Author: gedmurphy Date: Thu Oct 22 17:21:30 2015 New Revision: 69649
URL: http://svn.reactos.org/svn/reactos?rev=69649&view=rev Log: [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
Modified: trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h trunk/reactos/dll/win32/devmgr/precomp.h
Modified: trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/De... ============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp [iso-8859-1] Thu Oct 22 17:21:30 2015 @@ -700,13 +700,7 @@ } }
- if (Node->EnableDevice(Enable, NeedsReboot)) - { - Refresh(m_ViewType, true, true, Node->GetDeviceId()); - return true; - } - - return false; + return Node->EnableDevice(Enable, NeedsReboot); }
bool
Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/Ma... ============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp [iso-8859-1] Thu Oct 22 17:21:30 2015 @@ -20,6 +20,8 @@ #define BTN_DISABLE_DRV 3 #define BTN_UPDATE_DRV 4 #define BTN_UNINSTALL_DRV 5 + +#define REFRESH_TIMER 1
HINSTANCE g_hThisInstance = NULL; HINSTANCE g_hParentInstance = NULL; @@ -81,7 +83,8 @@ m_hMainWnd(NULL), m_hStatusBar(NULL), m_hToolBar(NULL), - m_CmdShow(0) + m_CmdShow(0), + m_RefreshPending(false) { m_szMainWndClass = L"DevMgmtWndClass"; } @@ -773,6 +776,42 @@ 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: { This->UpdateStatusBar(true);
Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/Ma... ============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h [iso-8859-1] Thu Oct 22 17:21:30 2015 @@ -17,6 +17,7 @@ HMENU m_hMenu; HMENU m_hActionMenu; int m_CmdShow; + bool m_RefreshPending;
public: CDeviceManager(void);
Modified: trunk/reactos/dll/win32/devmgr/precomp.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/precomp.h?... ============================================================================== --- trunk/reactos/dll/win32/devmgr/precomp.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/devmgr/precomp.h [iso-8859-1] Thu Oct 22 17:21:30 2015 @@ -12,6 +12,7 @@ #include <Cfgmgr32.h> #include <devguid.h> #include <process.h> +#include <dbt.h> #include <RegStr.h>
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit @@ -59,6 +60,7 @@ #include <strsafe.h> #include <regstr.h> #include <newdevp.h> +#include <dbt.h>
#include <setupapi.h> #include <commctrl.h>