mirror of
https://github.com/reactos/reactos.git
synced 2024-10-10 11:18:22 +00:00
update the hardware page on device status changes
svn path=/trunk/; revision=19904
This commit is contained in:
parent
5daa6cb919
commit
4c43e1c8b9
|
@ -679,10 +679,11 @@ AdvPropGeneralDlgProc(IN HWND hwndDlg,
|
||||||
|
|
||||||
case WM_DEVICECHANGE:
|
case WM_DEVICECHANGE:
|
||||||
{
|
{
|
||||||
/* FIXME - don't call UpdateDevInfo in all events */
|
/* FIXME - don't call UpdateDevInfo for all events */
|
||||||
UpdateDevInfo(hwndDlg,
|
UpdateDevInfo(hwndDlg,
|
||||||
dap,
|
dap,
|
||||||
TRUE);
|
TRUE);
|
||||||
|
Ret = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,15 +122,21 @@ static BOOL
|
||||||
DisplaySelectedDeviceProperties(IN PHARDWARE_PAGE_DATA hpd)
|
DisplaySelectedDeviceProperties(IN PHARDWARE_PAGE_DATA hpd)
|
||||||
{
|
{
|
||||||
PHWDEVINFO HwDevInfo;
|
PHWDEVINFO HwDevInfo;
|
||||||
|
SP_DEVINFO_DATA DevInfoData;
|
||||||
BOOL Ret = FALSE;
|
BOOL Ret = FALSE;
|
||||||
|
|
||||||
HwDevInfo = (PHWDEVINFO)ListViewGetSelectedItemData(hpd->hWndDevList);
|
HwDevInfo = (PHWDEVINFO)ListViewGetSelectedItemData(hpd->hWndDevList);
|
||||||
if (HwDevInfo != NULL)
|
if (HwDevInfo != NULL)
|
||||||
{
|
{
|
||||||
|
/* make a copy of the SP_DEVINFO_DATA structure on the stack, it may
|
||||||
|
become invalid in case the devices are updated */
|
||||||
|
DevInfoData = HwDevInfo->DevInfoData;
|
||||||
|
|
||||||
|
/* display the advanced properties */
|
||||||
Ret = DisplayDeviceAdvancedProperties(hpd->hWnd,
|
Ret = DisplayDeviceAdvancedProperties(hpd->hWnd,
|
||||||
NULL,
|
NULL,
|
||||||
HwDevInfo->ClassDevInfo->hDevInfo,
|
HwDevInfo->ClassDevInfo->hDevInfo,
|
||||||
&HwDevInfo->DevInfoData,
|
&DevInfoData,
|
||||||
hpd->hComCtl32,
|
hpd->hComCtl32,
|
||||||
NULL,
|
NULL,
|
||||||
0) != -1;
|
0) != -1;
|
||||||
|
@ -341,12 +347,59 @@ BuildDevicesList(IN PHARDWARE_PAGE_DATA hpd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static BOOL
|
||||||
|
DeviceIdMatch(IN HDEVINFO DeviceInfoSet,
|
||||||
|
IN PSP_DEVINFO_DATA DeviceInfoData,
|
||||||
|
IN LPCWSTR lpDeviceId)
|
||||||
|
{
|
||||||
|
DWORD DevIdLen;
|
||||||
|
LPWSTR lpQueriedDeviceId;
|
||||||
|
BOOL Ret = FALSE;
|
||||||
|
|
||||||
|
if (!SetupDiGetDeviceInstanceId(DeviceInfoSet,
|
||||||
|
DeviceInfoData,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
&DevIdLen) &&
|
||||||
|
GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||||
|
{
|
||||||
|
if (DevIdLen == wcslen(lpDeviceId) + 1)
|
||||||
|
{
|
||||||
|
lpQueriedDeviceId = HeapAlloc(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
DevIdLen * sizeof(WCHAR));
|
||||||
|
if (lpQueriedDeviceId != NULL)
|
||||||
|
{
|
||||||
|
if (SetupDiGetDeviceInstanceId(DeviceInfoSet,
|
||||||
|
DeviceInfoData,
|
||||||
|
lpQueriedDeviceId,
|
||||||
|
DevIdLen,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
Ret = (wcscmp(lpDeviceId,
|
||||||
|
lpQueriedDeviceId) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
lpQueriedDeviceId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
FillDevicesListViewControl(IN PHARDWARE_PAGE_DATA hpd)
|
FillDevicesListViewControl(IN PHARDWARE_PAGE_DATA hpd,
|
||||||
|
IN LPCWSTR lpSelectDeviceId OPTIONAL,
|
||||||
|
IN GUID *SelectedClassGuid OPTIONAL)
|
||||||
{
|
{
|
||||||
PHWCLASSDEVINFO ClassDevInfo, LastClassDevInfo;
|
PHWCLASSDEVINFO ClassDevInfo, LastClassDevInfo;
|
||||||
PHWDEVINFO HwDevInfo, LastHwDevInfo;
|
PHWDEVINFO HwDevInfo, LastHwDevInfo;
|
||||||
WCHAR szBuffer[255];
|
WCHAR szBuffer[255];
|
||||||
|
BOOL SelectedInClass;
|
||||||
INT ItemCount = 0;
|
INT ItemCount = 0;
|
||||||
|
|
||||||
BuildDevicesList(hpd);
|
BuildDevicesList(hpd);
|
||||||
|
@ -361,10 +414,13 @@ FillDevicesListViewControl(IN PHARDWARE_PAGE_DATA hpd)
|
||||||
HwDevInfo = ClassDevInfo->HwDevInfo;
|
HwDevInfo = ClassDevInfo->HwDevInfo;
|
||||||
LastHwDevInfo = HwDevInfo + ClassDevInfo->ItemCount;
|
LastHwDevInfo = HwDevInfo + ClassDevInfo->ItemCount;
|
||||||
|
|
||||||
|
SelectedInClass = (SelectedClassGuid != NULL &&
|
||||||
|
IsEqualGUID(SelectedClassGuid,
|
||||||
|
&ClassDevInfo->Guid));
|
||||||
while (HwDevInfo != LastHwDevInfo)
|
while (HwDevInfo != LastHwDevInfo)
|
||||||
{
|
{
|
||||||
INT iItem;
|
INT iItem;
|
||||||
LVITEM li;
|
LVITEM li = {0};
|
||||||
|
|
||||||
/* get the device name */
|
/* get the device name */
|
||||||
if (!HwDevInfo->HideDevice &&
|
if (!HwDevInfo->HideDevice &&
|
||||||
|
@ -375,8 +431,14 @@ FillDevicesListViewControl(IN PHARDWARE_PAGE_DATA hpd)
|
||||||
{
|
{
|
||||||
li.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT | LVIF_IMAGE;
|
li.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT | LVIF_IMAGE;
|
||||||
li.iItem = ItemCount;
|
li.iItem = ItemCount;
|
||||||
li.iSubItem = 0;
|
if ((ItemCount == 0 && lpSelectDeviceId == NULL) ||
|
||||||
li.state = (ItemCount == 0 ? LVIS_SELECTED : 0);
|
(SelectedInClass &&
|
||||||
|
DeviceIdMatch(ClassDevInfo->hDevInfo,
|
||||||
|
&HwDevInfo->DevInfoData,
|
||||||
|
lpSelectDeviceId)))
|
||||||
|
{
|
||||||
|
li.state = LVIS_SELECTED;
|
||||||
|
}
|
||||||
li.stateMask = LVIS_SELECTED;
|
li.stateMask = LVIS_SELECTED;
|
||||||
li.pszText = szBuffer;
|
li.pszText = szBuffer;
|
||||||
li.iImage = ClassDevInfo->ImageIndex;
|
li.iImage = ClassDevInfo->ImageIndex;
|
||||||
|
@ -415,6 +477,67 @@ FillDevicesListViewControl(IN PHARDWARE_PAGE_DATA hpd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static VOID
|
||||||
|
UpdateDevicesListViewControl(IN PHARDWARE_PAGE_DATA hpd)
|
||||||
|
{
|
||||||
|
PHWDEVINFO HwDevInfo;
|
||||||
|
GUID SelectedClassGuid = {0};
|
||||||
|
LPWSTR lpDeviceId = NULL;
|
||||||
|
|
||||||
|
/* if a device currently is selected, remember the device id so we can
|
||||||
|
select the device after the update if still present */
|
||||||
|
HwDevInfo = (PHWDEVINFO)ListViewGetSelectedItemData(hpd->hWndDevList);
|
||||||
|
if (HwDevInfo != NULL)
|
||||||
|
{
|
||||||
|
DWORD DevIdLen;
|
||||||
|
if (!SetupDiGetDeviceInstanceId(HwDevInfo->ClassDevInfo->hDevInfo,
|
||||||
|
&HwDevInfo->DevInfoData,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
&DevIdLen) &&
|
||||||
|
GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||||
|
{
|
||||||
|
SelectedClassGuid = HwDevInfo->DevInfoData.ClassGuid;
|
||||||
|
lpDeviceId = HeapAlloc(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
DevIdLen * sizeof(WCHAR));
|
||||||
|
if (lpDeviceId != NULL &&
|
||||||
|
!SetupDiGetDeviceInstanceId(HwDevInfo->ClassDevInfo->hDevInfo,
|
||||||
|
&HwDevInfo->DevInfoData,
|
||||||
|
lpDeviceId,
|
||||||
|
DevIdLen,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
lpDeviceId);
|
||||||
|
lpDeviceId = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* clear the devices list view control */
|
||||||
|
ListView_DeleteAllItems(hpd->hWndDevList);
|
||||||
|
|
||||||
|
/* free the device list */
|
||||||
|
FreeDevicesList(hpd);
|
||||||
|
|
||||||
|
/* build rebuild the device list and fill the list box again */
|
||||||
|
FillDevicesListViewControl(hpd,
|
||||||
|
lpDeviceId,
|
||||||
|
(lpDeviceId != NULL ?
|
||||||
|
&SelectedClassGuid :
|
||||||
|
NULL));
|
||||||
|
|
||||||
|
if (lpDeviceId != NULL)
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
lpDeviceId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static LRESULT
|
static LRESULT
|
||||||
CALLBACK
|
CALLBACK
|
||||||
ParentSubWndProc(IN HWND hwnd,
|
ParentSubWndProc(IN HWND hwnd,
|
||||||
|
@ -439,6 +562,16 @@ ParentSubWndProc(IN HWND hwnd,
|
||||||
HIWORD(lParam),
|
HIWORD(lParam),
|
||||||
SWP_NOZORDER);
|
SWP_NOZORDER);
|
||||||
}
|
}
|
||||||
|
else if (uMsg == WM_DEVICECHANGE && IsWindowVisible(hpd->hWnd))
|
||||||
|
{
|
||||||
|
/* forward a WM_DEVICECHANGE message to the hardware
|
||||||
|
page which wouldn't get the message itself as it is
|
||||||
|
a child window */
|
||||||
|
SendMessage(hpd->hWnd,
|
||||||
|
WM_DEVICECHANGE,
|
||||||
|
wParam,
|
||||||
|
lParam);
|
||||||
|
}
|
||||||
|
|
||||||
/* pass the message the the old window proc */
|
/* pass the message the the old window proc */
|
||||||
return CallWindowProc(hpd->ParentOldWndProc,
|
return CallWindowProc(hpd->ParentOldWndProc,
|
||||||
|
@ -739,6 +872,14 @@ HardwareDlgProc(IN HWND hwndDlg,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WM_DEVICECHANGE:
|
||||||
|
{
|
||||||
|
/* FIXME - don't call UpdateDevicesListViewControl for all events */
|
||||||
|
UpdateDevicesListViewControl(hpd);
|
||||||
|
Ret = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
{
|
{
|
||||||
hpd = (PHARDWARE_PAGE_DATA)lParam;
|
hpd = (PHARDWARE_PAGE_DATA)lParam;
|
||||||
|
@ -808,7 +949,9 @@ HardwareDlgProc(IN HWND hwndDlg,
|
||||||
InitializeDevicesList(hpd);
|
InitializeDevicesList(hpd);
|
||||||
|
|
||||||
/* fill the devices list view control */
|
/* fill the devices list view control */
|
||||||
FillDevicesListViewControl(hpd);
|
FillDevicesListViewControl(hpd,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
/* decide whether to show or hide the troubleshoot button */
|
/* decide whether to show or hide the troubleshoot button */
|
||||||
EnableTroubleShoot(hpd,
|
EnableTroubleShoot(hpd,
|
||||||
|
|
Loading…
Reference in a new issue