[SHELL32] Refresh UI on assoc change (SHOpenWithDialog) (#7076)

Fix file association UX.
JIRA issue: CORE-19670
- Check the return value of
  shell32!SHOpenWithDialog function.
- If changed, then update the UI display
  and internal data.
- Use OAIF_FORCE_REGISTRATION flag.
This commit is contained in:
Katayama Hirofumi MZ 2024-07-03 23:01:50 +09:00 committed by GitHub
parent edf6b805a7
commit b41332349a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 5 deletions

View file

@ -1049,8 +1049,12 @@ VOID COpenWithDialog::Accept()
if (pApp)
{
/* Set programm as default handler */
if (SendDlgItemMessage(m_hDialog, 14003, BM_GETCHECK, 0, 0) == BST_CHECKED)
if (IsDlgButtonChecked(m_hDialog, 14003) == BST_CHECKED)
{
m_pAppList->SetDefaultHandler(pApp, m_pInfo->pcszFile);
// FIXME: Update DefaultIcon registry
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_FLUSHNOWAIT, NULL, NULL);
}
/* Execute program */
if (m_pInfo->oaifInFlags & OAIF_EXEC)

View file

@ -742,8 +742,13 @@ CFileDefExt::GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
OPENASINFO oainfo;
oainfo.pcszFile = pFileDefExt->m_wszPath;
oainfo.pcszClass = NULL;
oainfo.oaifInFlags = OAIF_REGISTER_EXT|OAIF_FORCE_REGISTRATION;
return SUCCEEDED(SHOpenWithDialog(hwndDlg, &oainfo));
oainfo.oaifInFlags = OAIF_REGISTER_EXT | OAIF_FORCE_REGISTRATION;
if (SHOpenWithDialog(hwndDlg, &oainfo) == S_OK)
{
pFileDefExt->InitGeneralPage(hwndDlg);
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
}
break;
}
else if (LOWORD(wParam) == 14021 || LOWORD(wParam) == 14022 || LOWORD(wParam) == 14023) /* checkboxes */
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);

View file

@ -1673,6 +1673,19 @@ FileTypesDlg_OnItemChanging(HWND hwndDlg, PFILE_TYPE_ENTRY pEntry)
EnableWindow(GetDlgItem(hwndDlg, IDC_FILETYPES_DELETE), TRUE);
}
static VOID
FileTypesDlg_UpdateAppInfo(HWND hwndDlg, PFILE_TYPE_ENTRY pEntry)
{
pEntry->ProgramPath[0] = pEntry->AppName[0] = UNICODE_NULL;
DWORD cch = _countof(pEntry->ProgramPath);
if (S_OK == AssocQueryStringW(ASSOCF_INIT_IGNOREUNKNOWN, ASSOCSTR_EXECUTABLE,
pEntry->FileExtension, NULL, pEntry->ProgramPath, &cch))
{
QueryFileDescription(pEntry->ProgramPath, pEntry->AppName, _countof(pEntry->AppName));
}
}
// IDD_FOLDER_OPTIONS_FILETYPES
INT_PTR CALLBACK
FolderOptionsFileTypesDlg(
@ -1719,10 +1732,15 @@ FolderOptionsFileTypesDlg(
if (pEntry)
{
ZeroMemory(&Info, sizeof(Info));
Info.oaifInFlags = OAIF_ALLOW_REGISTRATION | OAIF_REGISTER_EXT;
Info.oaifInFlags = OAIF_FORCE_REGISTRATION | OAIF_REGISTER_EXT;
Info.pcszFile = pEntry->FileExtension;
Info.pcszClass = NULL;
SHOpenWithDialog(hwndDlg, &Info);
if (SHOpenWithDialog(hwndDlg, &Info) == S_OK)
{
FileTypesDlg_UpdateAppInfo(hwndDlg, pEntry);
FileTypesDlg_OnItemChanging(hwndDlg, pEntry);
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
}
}
break;