mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
[HOTPLUG] Add the context menu to the device tree view
This commit is contained in:
parent
7d1f270918
commit
bfdd6261f2
4 changed files with 102 additions and 8 deletions
|
@ -18,6 +18,7 @@
|
||||||
typedef struct _HOTPLUG_DATA
|
typedef struct _HOTPLUG_DATA
|
||||||
{
|
{
|
||||||
SP_CLASSIMAGELIST_DATA ImageListData;
|
SP_CLASSIMAGELIST_DATA ImageListData;
|
||||||
|
HMENU hPopupMenu;
|
||||||
DWORD dwFlags;
|
DWORD dwFlags;
|
||||||
} HOTPLUG_DATA, *PHOTPLUG_DATA;
|
} HOTPLUG_DATA, *PHOTPLUG_DATA;
|
||||||
|
|
||||||
|
@ -234,11 +235,9 @@ EnumHotpluggedDevices(
|
||||||
int idev;
|
int idev;
|
||||||
DWORD dwCapabilities, dwSize;
|
DWORD dwCapabilities, dwSize;
|
||||||
ULONG ulStatus, ulProblem;
|
ULONG ulStatus, ulProblem;
|
||||||
|
|
||||||
HTREEITEM hTreeItem;
|
HTREEITEM hTreeItem;
|
||||||
CONFIGRET cr;
|
CONFIGRET cr;
|
||||||
|
|
||||||
|
|
||||||
DPRINT1("EnumHotpluggedDevices()\n");
|
DPRINT1("EnumHotpluggedDevices()\n");
|
||||||
|
|
||||||
TreeView_DeleteAllItems(hwndDeviceTree);
|
TreeView_DeleteAllItems(hwndDeviceTree);
|
||||||
|
@ -299,6 +298,50 @@ EnumHotpluggedDevices(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
VOID
|
||||||
|
UpdateButtons(
|
||||||
|
HWND hwndDlg)
|
||||||
|
{
|
||||||
|
BOOL bEnabled;
|
||||||
|
|
||||||
|
bEnabled = (TreeView_GetCount(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_DEVICE_TREE)) != 0);
|
||||||
|
|
||||||
|
EnableWindow(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_PROPERTIES), bEnabled);
|
||||||
|
EnableWindow(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_STOP), bEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
VOID
|
||||||
|
ShowContextMenu(
|
||||||
|
HWND hwndDlg,
|
||||||
|
HWND hwndTreeView,
|
||||||
|
PHOTPLUG_DATA pHotplugData)
|
||||||
|
{
|
||||||
|
HTREEITEM hTreeItem;
|
||||||
|
RECT rc;
|
||||||
|
POINT pt;
|
||||||
|
|
||||||
|
hTreeItem = TreeView_GetSelection(hwndTreeView);
|
||||||
|
if (hTreeItem == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TreeView_GetItemRect(hwndTreeView, hTreeItem, &rc, TRUE);
|
||||||
|
|
||||||
|
pt.x = (rc.left + rc.right) / 2;
|
||||||
|
pt.y = (rc.top + rc.bottom) / 2;
|
||||||
|
ClientToScreen(hwndTreeView, &pt);
|
||||||
|
TrackPopupMenu(GetSubMenu(pHotplugData->hPopupMenu, 0),
|
||||||
|
TPM_LEFTALIGN | TPM_TOPALIGN,
|
||||||
|
pt.x,
|
||||||
|
pt.y,
|
||||||
|
0,
|
||||||
|
hwndDlg,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
INT_PTR
|
INT_PTR
|
||||||
CALLBACK
|
CALLBACK
|
||||||
SafeRemovalDlgProc(
|
SafeRemovalDlgProc(
|
||||||
|
@ -309,14 +352,12 @@ SafeRemovalDlgProc(
|
||||||
{
|
{
|
||||||
PHOTPLUG_DATA pHotplugData;
|
PHOTPLUG_DATA pHotplugData;
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(lParam);
|
|
||||||
|
|
||||||
pHotplugData = (PHOTPLUG_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
pHotplugData = (PHOTPLUG_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
||||||
|
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
pHotplugData = HeapAlloc(GetProcessHeap(), 0, sizeof(HOTPLUG_DATA));
|
pHotplugData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HOTPLUG_DATA));
|
||||||
if (pHotplugData != NULL)
|
if (pHotplugData != NULL)
|
||||||
{
|
{
|
||||||
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pHotplugData);
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pHotplugData);
|
||||||
|
@ -324,6 +365,8 @@ SafeRemovalDlgProc(
|
||||||
pHotplugData->ImageListData.cbSize = sizeof(pHotplugData->ImageListData);
|
pHotplugData->ImageListData.cbSize = sizeof(pHotplugData->ImageListData);
|
||||||
SetupDiGetClassImageList(&pHotplugData->ImageListData);
|
SetupDiGetClassImageList(&pHotplugData->ImageListData);
|
||||||
|
|
||||||
|
pHotplugData->hPopupMenu = LoadMenu(hApplet, MAKEINTRESOURCE(IDM_POPUP_DEVICE_TREE));
|
||||||
|
|
||||||
pHotplugData->dwFlags = GetHotPlugFlags();
|
pHotplugData->dwFlags = GetHotPlugFlags();
|
||||||
|
|
||||||
if (pHotplugData->dwFlags & HOTPLUG_DISPLAY_DEVICE_COMPONENTS)
|
if (pHotplugData->dwFlags & HOTPLUG_DISPLAY_DEVICE_COMPONENTS)
|
||||||
|
@ -335,6 +378,7 @@ SafeRemovalDlgProc(
|
||||||
|
|
||||||
EnumHotpluggedDevices(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_DEVICE_TREE),
|
EnumHotpluggedDevices(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_DEVICE_TREE),
|
||||||
pHotplugData);
|
pHotplugData);
|
||||||
|
UpdateButtons(hwndDlg);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
@ -384,6 +428,23 @@ SafeRemovalDlgProc(
|
||||||
{
|
{
|
||||||
EnumHotpluggedDevices(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_DEVICE_TREE),
|
EnumHotpluggedDevices(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_DEVICE_TREE),
|
||||||
pHotplugData);
|
pHotplugData);
|
||||||
|
UpdateButtons(hwndDlg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_NOTIFY:
|
||||||
|
if (((LPNMHDR)lParam)->idFrom == IDC_SAFE_REMOVE_DEVICE_TREE)
|
||||||
|
{
|
||||||
|
if (((LPNMHDR)lParam)->code == NM_RCLICK)
|
||||||
|
{
|
||||||
|
if (pHotplugData != NULL)
|
||||||
|
{
|
||||||
|
ShowContextMenu(hwndDlg,
|
||||||
|
((LPNMHDR)lParam)->hwndFrom,
|
||||||
|
pHotplugData);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -396,6 +457,9 @@ SafeRemovalDlgProc(
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
if (pHotplugData != NULL)
|
if (pHotplugData != NULL)
|
||||||
{
|
{
|
||||||
|
if (pHotplugData->hPopupMenu != NULL)
|
||||||
|
DestroyMenu(pHotplugData->hPopupMenu);
|
||||||
|
|
||||||
SetupDiDestroyClassImageList(&pHotplugData->ImageListData);
|
SetupDiDestroyClassImageList(&pHotplugData->ImageListData);
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, pHotplugData);
|
HeapFree(GetProcessHeap(), 0, pHotplugData);
|
||||||
|
|
|
@ -16,3 +16,15 @@ BEGIN
|
||||||
AUTOCHECKBOX "&Gerätekomponenten anzeigen", IDC_SAFE_REMOVE_DISPLAY_COMPONENTS, 7, 208, 112, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
AUTOCHECKBOX "&Gerätekomponenten anzeigen", IDC_SAFE_REMOVE_DISPLAY_COMPONENTS, 7, 208, 112, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
||||||
PUSHBUTTON "&Schließen", IDCLOSE, 216, 224, 55, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
PUSHBUTTON "&Schließen", IDCLOSE, 216, 224, 55, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
|
/* Menus */
|
||||||
|
|
||||||
|
IDM_POPUP_DEVICE_TREE MENU
|
||||||
|
BEGIN
|
||||||
|
POPUP ""
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "Beenden", IDM_STOP
|
||||||
|
MENUITEM "Eigenschaften", IDM_PROPERTIES
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
|
@ -16,3 +16,15 @@ BEGIN
|
||||||
AUTOCHECKBOX "&Display device components", IDC_SAFE_REMOVE_DISPLAY_COMPONENTS, 7, 208, 112, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
AUTOCHECKBOX "&Display device components", IDC_SAFE_REMOVE_DISPLAY_COMPONENTS, 7, 208, 112, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
||||||
PUSHBUTTON "&Close", IDCLOSE, 216, 224, 55, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
PUSHBUTTON "&Close", IDCLOSE, 216, 224, 55, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
|
/* Menus */
|
||||||
|
|
||||||
|
IDM_POPUP_DEVICE_TREE MENU
|
||||||
|
BEGIN
|
||||||
|
POPUP ""
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "Stop", IDM_STOP
|
||||||
|
MENUITEM "Properties", IDM_PROPERTIES
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/* Icon ids */
|
/* Icon IDs */
|
||||||
#define IDI_HOTPLUG 100
|
#define IDI_HOTPLUG 100
|
||||||
|
|
||||||
/* Dialog ids */
|
/* Dialog IDs */
|
||||||
#define IDC_STATIC -1
|
#define IDC_STATIC -1
|
||||||
|
|
||||||
#define IDD_SAFE_REMOVE_HARDWARE_DIALOG 300
|
#define IDD_SAFE_REMOVE_HARDWARE_DIALOG 300
|
||||||
|
@ -16,6 +16,12 @@
|
||||||
|
|
||||||
#define IDD_CONFIRM_STOP_HARDWARE_DIALOG 310
|
#define IDD_CONFIRM_STOP_HARDWARE_DIALOG 310
|
||||||
|
|
||||||
/* Resource strings ids */
|
/* Menu IDs */
|
||||||
|
#define IDM_POPUP_DEVICE_TREE 500
|
||||||
|
#define IDM_STOP 501
|
||||||
|
#define IDM_PROPERTIES 502
|
||||||
|
|
||||||
|
/* Resource strings IDs */
|
||||||
#define IDS_CPLNAME 1000
|
#define IDS_CPLNAME 1000
|
||||||
#define IDS_CPLDESCRIPTION 1001
|
#define IDS_CPLDESCRIPTION 1001
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue