mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
[HOTPLUG] Add device properties dialog support (#5812)
Clicking at "Properties" button or right-click menu now opens properties dialog for the selected device.
This commit is contained in:
parent
6f86e11aa2
commit
7f5c59a0b3
1 changed files with 73 additions and 2 deletions
|
@ -157,13 +157,13 @@ InsertDeviceTreeItem(
|
||||||
tvItem.hParent = hParent;
|
tvItem.hParent = hParent;
|
||||||
tvItem.hInsertAfter = TVI_LAST;
|
tvItem.hInsertAfter = TVI_LAST;
|
||||||
|
|
||||||
tvItem.item.mask = TVIF_STATE | TVIF_TEXT /*| TVIF_PARAM*/ | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
|
tvItem.item.mask = TVIF_STATE | TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
|
||||||
tvItem.item.state = TVIS_EXPANDED;
|
tvItem.item.state = TVIS_EXPANDED;
|
||||||
tvItem.item.stateMask = TVIS_EXPANDED;
|
tvItem.item.stateMask = TVIS_EXPANDED;
|
||||||
tvItem.item.pszText = szDisplayName;
|
tvItem.item.pszText = szDisplayName;
|
||||||
tvItem.item.iImage = nClassImage;
|
tvItem.item.iImage = nClassImage;
|
||||||
tvItem.item.iSelectedImage = nClassImage;
|
tvItem.item.iSelectedImage = nClassImage;
|
||||||
tvItem.item.lParam = (LPARAM)NULL;
|
tvItem.item.lParam = (LPARAM)DevInst;
|
||||||
|
|
||||||
return TreeView_InsertItem(hwndDeviceTree, &tvItem);
|
return TreeView_InsertItem(hwndDeviceTree, &tvItem);
|
||||||
}
|
}
|
||||||
|
@ -344,6 +344,69 @@ ShowContextMenu(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
DEVINST
|
||||||
|
GetSelectedDeviceInst(
|
||||||
|
_In_ HWND hwndDeviceTree)
|
||||||
|
{
|
||||||
|
HTREEITEM hTreeItem;
|
||||||
|
TVITEMW item;
|
||||||
|
|
||||||
|
hTreeItem = TreeView_GetSelection(hwndDeviceTree);
|
||||||
|
if (hTreeItem == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ZeroMemory(&item, sizeof(item));
|
||||||
|
item.mask = TVIF_PARAM;
|
||||||
|
item.hItem = hTreeItem;
|
||||||
|
|
||||||
|
TreeView_GetItem(hwndDeviceTree, &item);
|
||||||
|
|
||||||
|
return item.lParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
VOID
|
||||||
|
ShowDeviceProperties(
|
||||||
|
_In_ HWND hwndParent,
|
||||||
|
_In_ DEVINST DevInst)
|
||||||
|
{
|
||||||
|
ULONG ulSize;
|
||||||
|
CONFIGRET cr;
|
||||||
|
LPWSTR pszDevId;
|
||||||
|
|
||||||
|
cr = CM_Get_Device_ID_Size(&ulSize, DevInst, 0);
|
||||||
|
if (cr != CR_SUCCESS || ulSize == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Take the terminating NULL into account */
|
||||||
|
ulSize++;
|
||||||
|
|
||||||
|
pszDevId = HeapAlloc(GetProcessHeap(), 0, ulSize * sizeof(WCHAR));
|
||||||
|
if (pszDevId == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
cr = CM_Get_Device_IDW(DevInst, pszDevId, ulSize, 0);
|
||||||
|
if (cr == CR_SUCCESS)
|
||||||
|
{
|
||||||
|
typedef int (WINAPI *PFDEVICEPROPERTIESW)(HWND, LPCWSTR, LPCWSTR, BOOL);
|
||||||
|
HMODULE hDevMgrDll;
|
||||||
|
PFDEVICEPROPERTIESW pDevicePropertiesW;
|
||||||
|
|
||||||
|
hDevMgrDll = LoadLibraryW(L"devmgr.dll");
|
||||||
|
if (hDevMgrDll != NULL)
|
||||||
|
{
|
||||||
|
pDevicePropertiesW = (PFDEVICEPROPERTIESW)GetProcAddress(hDevMgrDll, "DevicePropertiesW");
|
||||||
|
if (pDevicePropertiesW != NULL)
|
||||||
|
pDevicePropertiesW(hwndParent, NULL, pszDevId, FALSE);
|
||||||
|
|
||||||
|
FreeLibrary(hDevMgrDll);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, pszDevId);
|
||||||
|
}
|
||||||
|
|
||||||
INT_PTR
|
INT_PTR
|
||||||
CALLBACK
|
CALLBACK
|
||||||
SafeRemovalDlgProc(
|
SafeRemovalDlgProc(
|
||||||
|
@ -434,6 +497,14 @@ SafeRemovalDlgProc(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IDC_SAFE_REMOVE_PROPERTIES:
|
||||||
|
case IDM_PROPERTIES:
|
||||||
|
{
|
||||||
|
HWND hwndDevTree = GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_DEVICE_TREE);
|
||||||
|
ShowDeviceProperties(hwndDlg, GetSelectedDeviceInst(hwndDevTree));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue