I would like to make a semblance of a standard Windows Explorer, just convenient, with the chips I need. I can not find the information, is it possible to call the standard context menu of the explorer (pop-up by clicking the right mouse button)?

    2 answers 2

    procedure TForm1.PopupMenu1Popup(Sender: TObject); var ContextMenu : IContextMenu; menu : HMENU; begin FIShellFolder.GetUIObjectOf(Handle, 1, ShellItem(ListView.Selected.Index). ID, IID_IContextMenu, nil, ContextMenu); //FIShellFolder-переменная, которую нужно инициализировать "выше" menu := CreatePopupMenu(); ContextMenu.QueryContextMenu(menu, 0, 1, $7FFF, CMF_EXPLORE); TrackPopupMenu(menu, TPM_LEFTALIGN or TPM_LEFTBUTTON or TPM_RIGHTBUTTON or TPM_RETURNCMD, Mouse.CursorPos.x, Mouse.CursorPos.y, 0, Handle, nil); DestroyMenu(menu); end; 

    I think the example on Delphi will help ..

    • I tried your example, but I wrote an error: [Pascal Error] Sdup.pas (65): E2003 Undeclared identifier: 'IContextMenu' [Pascal Error] Sdup.pas (68): E2003 Undeclared identifier: 'FIShellFolder' [Pascal Error] Sdup .pas (68): E2003 Undeclared identifier: 'ShellItem' But for some reason, refactoring could not find a unit suitable for them. - Ilya Efremov
    • ActiveX, ComObj, ShlObj - Ivlev Denis
    • // FIShellFolder-variable, which needs to be initialized "higher" Eyes than are sheathed? !!!! - Ivlev Denis
    • Thank! I found an example of delphisources.ru/files/sources/system/2006_year/ ... For this example, your supplement fits without question, everything is built on Shell. Those. The menu is now called, but it is inactive. How to make it process the selection of an item from the list (open, copy .., properties)? - Ilya Efremov

    Explorer context menu is a COM object that implements IContextMenu and IShellExtInt interfaces. Perhaps there is some way that allows you to reuse this COM in your application. You can start searching for a suitable API from here: Creating Shell Extension Handlers .