https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7f5c59a0b3e3b731f118c…
commit 7f5c59a0b3e3b731f118c7654972c88b2418fa82
Author: Thamatip Chitpong <thamatip.chitpong(a)reactos.org>
AuthorDate: Mon Oct 23 18:53:08 2023 +0700
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Oct 23 18:53:08 2023 +0700
[HOTPLUG] Add device properties dialog support (#5812)
Clicking at "Properties" button or right-click menu now opens properties
dialog for the selected device.
---
dll/cpl/hotplug/hotplug.c | 75 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 73 insertions(+), 2 deletions(-)
diff --git a/dll/cpl/hotplug/hotplug.c b/dll/cpl/hotplug/hotplug.c
index 7f2930f26cc..15dea9c7583 100644
--- a/dll/cpl/hotplug/hotplug.c
+++ b/dll/cpl/hotplug/hotplug.c
@@ -157,13 +157,13 @@ InsertDeviceTreeItem(
tvItem.hParent = hParent;
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.stateMask = TVIS_EXPANDED;
tvItem.item.pszText = szDisplayName;
tvItem.item.iImage = nClassImage;
tvItem.item.iSelectedImage = nClassImage;
- tvItem.item.lParam = (LPARAM)NULL;
+ tvItem.item.lParam = (LPARAM)DevInst;
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
CALLBACK
SafeRemovalDlgProc(
@@ -434,6 +497,14 @@ SafeRemovalDlgProc(
}
}
break;
+
+ case IDC_SAFE_REMOVE_PROPERTIES:
+ case IDM_PROPERTIES:
+ {
+ HWND hwndDevTree = GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_DEVICE_TREE);
+ ShowDeviceProperties(hwndDlg, GetSelectedDeviceInst(hwndDevTree));
+ break;
+ }
}
break;