[SHELL32] Implement the Select verb in CommDlgBrowser (#7225)

- Use Select instead of Open default menu item.
- Support CDB2GVF_NOSELECTVERB, CDB2GVF_NOINCLUDEITEM and CDB2GVF_SHOWALLFILES flags.
This commit is contained in:
Whindmar Saksit 2024-08-15 18:40:32 +02:00 committed by GitHub
parent 7d532f8792
commit d5f6b8c50b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 342 additions and 12 deletions

View file

@ -48,8 +48,9 @@ enum {
DEFVIEW_ARRANGESORT_MAX = DEFVIEW_ARRANGESORT_MAXENUM + 1, // Reserve one extra for the current sort-by column
DVIDM_ARRANGESORT_LAST = FCIDM_SHVIEWLAST,
DVIDM_ARRANGESORT_FIRST = DVIDM_ARRANGESORT_LAST - (DEFVIEW_ARRANGESORT_MAX - 1),
DVIDM_COMMDLG_SELECT = DVIDM_ARRANGESORT_FIRST - 1,
DVIDM_CONTEXTMENU_LAST = DVIDM_ARRANGESORT_FIRST - 1,
DVIDM_CONTEXTMENU_LAST = DVIDM_COMMDLG_SELECT - 1,
// FIXME: FCIDM_SHVIEWFIRST is 0 and using that with QueryContextMenu is a
// bad idea because it hides bugs related to the ids in ici.lpVerb.
// CONTEXT_MENU_BASE_ID acknowledges this but failed to apply the fix everywhere.
@ -336,6 +337,18 @@ public:
HRESULT SaveViewState(IStream *pStream);
void UpdateFolderViewFlags();
DWORD GetCommDlgViewFlags()
{
CComPtr<ICommDlgBrowser2> pcdb2;
if (m_pCommDlgBrowser && SUCCEEDED(m_pCommDlgBrowser->QueryInterface(IID_PPV_ARG(ICommDlgBrowser2, &pcdb2))))
{
DWORD flags;
if (SUCCEEDED(pcdb2->GetViewFlags(&flags)))
return flags;
}
return 0;
}
// *** IOleWindow methods ***
STDMETHOD(GetWindow)(HWND *lphwnd) override;
STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode) override;
@ -624,7 +637,7 @@ HRESULT CDefView::IncludeObject(PCUITEMID_CHILD pidl)
{
HRESULT ret = S_OK;
if (m_pCommDlgBrowser.p != NULL)
if (m_pCommDlgBrowser && !(GetCommDlgViewFlags() & CDB2GVF_NOINCLUDEITEM))
{
TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl);
ret = m_pCommDlgBrowser->IncludeObject(this, pidl);
@ -1477,6 +1490,9 @@ HRESULT CDefView::FillList(BOOL IsRefreshCommand)
SHELLSTATE shellstate;
SHGetSetSettings(&shellstate, SSF_SHOWALLOBJECTS | SSF_SHOWSUPERHIDDEN, FALSE);
if (GetCommDlgViewFlags() & CDB2GVF_SHOWALLFILES)
shellstate.fShowAllObjects = shellstate.fShowSuperHidden = TRUE;
if (shellstate.fShowAllObjects)
{
dFlags |= SHCONTF_INCLUDEHIDDEN;
@ -2182,6 +2198,15 @@ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b
if (FAILED_UNEXPECTEDLY(hResult))
return 0;
if (m_pCommDlgBrowser && !(GetCommDlgViewFlags() & CDB2GVF_NOSELECTVERB))
{
HMENU hMenuSource = LoadMenuW(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCEW(IDM_DVSELECT));
Shell_MergeMenus(m_hContextMenu, GetSubMenu(hMenuSource, 0), 0, DVIDM_COMMDLG_SELECT, 0xffff, MM_ADDSEPARATOR | MM_DONTREMOVESEPS);
DestroyMenu(hMenuSource);
SetMenuDefaultItem(m_hContextMenu, DVIDM_COMMDLG_SELECT, MF_BYCOMMAND);
// TODO: ICommDlgBrowser2::GetDefaultMenuText == S_OK
}
// There is no position requested, so try to find one
if (lParam == ~0)
{
@ -2215,21 +2240,25 @@ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b
m_ListView.ClientToScreen(&pt);
}
CComPtr<ICommDlgBrowser2> pcdb2;
if (m_pCommDlgBrowser && SUCCEEDED(m_pCommDlgBrowser->QueryInterface(IID_PPV_ARG(ICommDlgBrowser2, &pcdb2))))
pcdb2->Notify(static_cast<IShellView*>(this), CDB2N_CONTEXTMENU_START);
// This runs the message loop, calling back to us with f.e. WM_INITPOPUP (hence why m_hContextMenu and m_pCM exist)
uCommand = TrackPopupMenu(m_hContextMenu,
TPM_LEFTALIGN | TPM_RETURNCMD | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
pt.x, pt.y, 0, m_hWnd, NULL);
if (uCommand == 0)
return 0;
if (uCommand >= DVIDM_ARRANGESORT_FIRST && uCommand <= DVIDM_ARRANGESORT_LAST)
return SendMessage(WM_COMMAND, uCommand, 0);
if (uCommand == FCIDM_SHVIEW_OPEN && OnDefaultCommand() == S_OK)
return 0;
InvokeContextMenuCommand(m_pCM, MAKEINTRESOURCEA(uCommand - CONTEXT_MENU_BASE_ID), &pt);
{
SendMessage(WM_COMMAND, uCommand, 0);
}
else if (uCommand != 0 && !(uCommand == DVIDM_COMMDLG_SELECT && OnDefaultCommand() == S_OK))
{
InvokeContextMenuCommand(m_pCM, MAKEINTRESOURCEA(uCommand - CONTEXT_MENU_BASE_ID), &pt);
}
if (pcdb2)
pcdb2->Notify(static_cast<IShellView*>(this), CDB2N_CONTEXTMENU_DONE);
return 0;
}

View file

@ -876,7 +876,7 @@ CDefaultContextMenu::QueryContextMenu(
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, cIds);
/* Add the default part of the menu */
HMENU hmenuDefault = LoadMenu(_AtlBaseModule.GetResourceInstance(), L"MENU_SHV_FILE");
HMENU hmenuDefault = LoadMenuW(_AtlBaseModule.GetResourceInstance(), L"MENU_SHV_FILE");
/* Remove uneeded entries */
if (!(rfg & SFGAO_CANMOVE))
@ -1260,6 +1260,13 @@ CDefaultContextMenu::BrowserFlagsFromVerb(LPCMINVOKECOMMANDINFOEX lpcmi, PStatic
else
FlagsName = L"BrowserFlags";
CComPtr<ICommDlgBrowser> pcdb;
if (SUCCEEDED(psb->QueryInterface(IID_PPV_ARG(ICommDlgBrowser, &pcdb))))
{
if (LOBYTE(GetVersion()) < 6 || FlagsName[0] == 'E')
return 0; // Don't browse in-place
}
/* Try to get the flag from the verb */
hr = StringCbPrintfW(wszKey, sizeof(wszKey), L"shell\\%s", pEntry->Verb.GetString());
if (FAILED_UNEXPECTEDLY(hr))

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Търсене на папка"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Browse for Folder"

View file

@ -96,6 +96,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Procházet..."

View file

@ -95,6 +95,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Søg efter Mappe"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Verzeichnis auswählen"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Αναζήτηση φακέλου"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Browse for Folder"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Browse for Folder"

View file

@ -97,6 +97,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Explorar carpeta"

View file

@ -95,6 +95,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Vali kaust"

View file

@ -95,6 +95,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Karpeta esploratu"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Valitse Kansio"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Sé&lectionner", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Parcourir"

View file

@ -95,6 +95,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "בחירת תיקיה"

View file

@ -95,6 +95,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "फोल्डर खोंजे"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Mappák böngészése"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Jelajah Folder"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Sfoglia Cartella"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "フォルダの参照"

View file

@ -95,6 +95,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "폴더 찾아보기"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Browse for Folder"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Bla etter mappe"

View file

@ -97,6 +97,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Wybierz folder"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Procurar pasta"

View file

@ -98,6 +98,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Procurar pasta"

View file

@ -96,6 +96,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Specificare folder"

View file

@ -97,6 +97,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Обзор"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Browse for Folder"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Browse for Folder"

View file

@ -95,6 +95,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Shfleto për Dosje"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Bläddra efter mapp"

View file

@ -97,6 +97,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Dizin İçin Göz At"

View file

@ -88,6 +88,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Огляд папок"

View file

@ -98,6 +98,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "浏览文件夹"

View file

@ -96,6 +96,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "瀏覽資料夾"

View file

@ -97,6 +97,14 @@ BEGIN
END
END
IDM_DVSELECT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Se&lect", 0
END
END
IDD_BROWSE_FOR_FOLDER DIALOGEX 15, 40, 188, 192
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "瀏覽資料夾"

View file

@ -878,6 +878,7 @@
#define IDM_COPYHERE 0x7
#define IDM_MOVEHERE 0x8
#define IDM_LINKHERE 0xB
#define IDM_DVSELECT 0x104
#define IDM_MYDOCUMENTS 516
#define IDM_MYPICTURES 518

View file

@ -1442,6 +1442,11 @@ cpp_quote("#define CDBOSC_STATECHANGE 0x00000004")
]
interface ICommDlgBrowser2 : ICommDlgBrowser
{
cpp_quote("#define CDB2N_CONTEXTMENU_DONE 1")
cpp_quote("#define CDB2N_CONTEXTMENU_START 2")
cpp_quote("#define CDB2GVF_SHOWALLFILES 0x00000001")
cpp_quote("#define CDB2GVF_NOSELECTVERB 0x00000008")
cpp_quote("#define CDB2GVF_NOINCLUDEITEM 0x00000010 /* IncludeObject should not be called */")
HRESULT Notify(
[in] IShellView *ppshv,