[NEWDEV] Fix bad use of PropSheet_SetCurSelByID (#7574)

PropSheet_SetCurSelByID() was badly called in response of PSN_WIZBACK or
PSN_WIZNEXT notifications. See the reference on these notification codes:

https://learn.microsoft.com/en-us/windows/win32/controls/psn-wizback

> Returns 0 to allow the wizard to go to the previous page. Returns -1 to
> prevent the wizard from changing pages. To display a particular page,
> return its dialog resource identifier.
> (...)
> To set the return value, the dialog box procedure for the page must call
> the SetWindowLong function with the DWL_MSGRESULT value and return TRUE.

This bug sometimes causes the wrong page to appear (e.g. "Previous" in
IDD_NODRIVER should come back in IDD_CHSOURCE, but goes to IDD_WELCOME).
This commit is contained in:
Denis Robert 2024-12-23 14:24:21 +01:00 committed by GitHub
parent 0743faf2e3
commit 6f60301d25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -545,9 +545,9 @@ WelcomeDlgProc(
if (SendDlgItemMessage(hwndDlg, IDC_RADIO_AUTO, BM_GETCHECK, (WPARAM)0, (LPARAM)0) == BST_CHECKED)
{
if (PrepareFoldersToScan(DevInstData, TRUE, FALSE, NULL))
PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_SEARCHDRV);
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, IDD_SEARCHDRV);
else
PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_INSTALLFAILED);
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, IDD_INSTALLFAILED);
}
return TRUE;
@ -759,11 +759,11 @@ CHSourceDlgProc(
IsDlgButtonChecked(hwndDlg, IDC_CHECK_PATH),
GetDlgItem(hwndDlg, IDC_COMBO_PATH)))
{
PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_SEARCHDRV);
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, IDD_SEARCHDRV);
}
else
{
PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_INSTALLFAILED);
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, IDD_INSTALLFAILED);
}
}
else
@ -1059,7 +1059,7 @@ NoDriverDlgProc(
hwndControl = GetDlgItem(GetParent(hwndDlg), IDCANCEL);
ShowWindow(hwndControl, SW_SHOW);
EnableWindow(hwndControl, TRUE);
PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_CHSOURCE);
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, IDD_CHSOURCE);
return TRUE;
case PSN_WIZFINISH: