Skip to content

Drag & drop context menu on right‐click

0x5BFA edited this page Jan 9, 2025 · 6 revisions

Trigger the context menu

Image

  1. Register your app with RegisterDragDrop.
  2. In the IDropTarget.Drop method:
    1. Obtain the IShellFolder interface for the drop path.
    2. Get the IDropTarget interface from this folder.
    3. Forward the IDataObject to the DragEnter and Drop methods.
    4. The Drop method will display the correct context menu.
void InvokeDragAndDropRMenu(IDropTarget* pDropTarget, IDataObject* pData, DWORD dwKeys, POINTL point, DWORD* pdwEffect)
{
    ComPtr<IShellFolder> pShellFolder = default;
    ComPtr<IDropTarget> pFolderDropTarget = default;

    hr = GetShellFolder(pszPath, pShellFolder.GetAddressOf());
    hr = pShellFolder.Get()->CreateViewObject(pShellFolder, &IID_IDropTarget, pFolderDropTarget.GetAddressOf());
    hr = pFolderDropTarget.Get()->DragEnter(pFolderDropTarget, pData, PInvoke.MK_RBUTTON, point, pdwEffect);
    hr = pFolderDropTarget.Get()->Drop(pFolderDropTarget, pData, PInvoke.MK_RBUTTON, point, pdwEffect);
}

Mechanism

References

Controls
  • FolderBrowser
  • DetailsFolderView
  • GridFolderView
  • ListFolderView
  • TilesFolderView
  • ContentFolderView
  • ColumnsFolderView
  • TreeFolderView
  • GalleryFolderView
  • HomeFolderView
  • RectanglurSelectionVisual
  • DataGrid
  • SidebarView
  • Omnibar
  • Toolbar
  • FilePreviewPresenter
  • ColorTags
  • RichTokens
  • TerminalView
API
  • WindowsStorable
  • ArchiveStorable
  • HomeStorable
  • FtpStorable
  • SftpStorable
  • WebDAVStorable
Infrastructure
  • CommandManager
  • MultitaskingManager
  • DialogManager
  • AppSettings
  • OperationServer

Copyright © 2025 0x5BFA. All rights reserved. Do not copy or redistribute modified versions.

Clone this wiki locally