Skip to content

Commit

Permalink
[HOTPLUG] Main dialog: Fix UpdateButtons
Browse files Browse the repository at this point in the history
- Select first item after device enum, like Windows does
- Rename the function to UpdateDialog
  • Loading branch information
TAN-Gaming committed Oct 31, 2023
1 parent 88c9cb4 commit a5f5e08
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions dll/cpl/hotplug/hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,20 @@ SetHotPlugFlags(

static
VOID
UpdateButtons(
HWND hwndDlg)
UpdateDialog(
_In_ HWND hwndDlg)
{
BOOL bEnabled;
HWND hwndDeviceTree;
BOOL bHasItem;

bEnabled = (TreeView_GetCount(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_DEVICE_TREE)) != 0);
hwndDeviceTree = GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_DEVICE_TREE);

EnableWindow(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_PROPERTIES), bEnabled);
EnableWindow(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_STOP), bEnabled);
bHasItem = (TreeView_GetCount(hwndDeviceTree) != 0);
if (bHasItem)
TreeView_SelectItem(hwndDeviceTree, TreeView_GetFirstVisible(hwndDeviceTree));

EnableWindow(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_PROPERTIES), bHasItem);
EnableWindow(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_STOP), bHasItem);
}


Expand Down Expand Up @@ -255,7 +260,7 @@ SafeRemovalDlgProc(
TVSIL_NORMAL);

EnumHotpluggedDevices(pHotplugData);
UpdateButtons(hwndDlg);
UpdateDialog(hwndDlg);
}
return TRUE;

Expand All @@ -280,6 +285,7 @@ SafeRemovalDlgProc(
SetHotPlugFlags(pHotplugData->dwFlags);

EnumHotpluggedDevices(pHotplugData);
UpdateDialog(hwndDlg);
}
}
break;
Expand Down Expand Up @@ -326,7 +332,7 @@ SafeRemovalDlgProc(
if (pHotplugData != NULL)
{
EnumHotpluggedDevices(pHotplugData);
UpdateButtons(hwndDlg);
UpdateDialog(hwndDlg);
}
}
break;
Expand Down

0 comments on commit a5f5e08

Please sign in to comment.