简体   繁体   English

如何获得右键单击文件夹背景的完整Shell上下文菜单

[英]How to obtain full shell context menu of right-click a folder background

I can obtain shell interface IShellView , and I can get its context menu of right click the folder view's white area (background), following is my code: 我可以获得外壳程序接口IShellView ,并且可以右键单击文件夹视图的白色区域(背景)获取其上下文菜单,以下是我的代码:

...
IShellFolder* psf = NULL;
HRESULT hr = psfDesk->BindToObject(g_pidlSelectingFolder, NULL, IID_PPV_ARGS(&psf));
...
IShellView* pShellView = NULL;
if (FAILED(psfSelf->CreateViewObject(hParent, IID_PPV_ARGS(&pShellView))))
    return;

IContextMenu3* pcm3 = NULL;
hr = pShellView->GetItemObject(SVGIO_BACKGROUND, IID_IContextMenu3, (LPVOID*)&pcm3);
HMENU hMenu = ::CreatePopupMenu();
pcm3->QueryContextMenu(g_hMenu, 0, 1, 10000, CMF_NORMAL);

POINT pt;
::GetCursorPos(&pt);
BOOL nCommandID = TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_LEFTALIGN, pt.x, pt.y, 0, hParentWnd, NULL);
if (nCommandID == ...)  ...
DestroyMenu(hMenu);

Both following images are my shortcut menu and the full shell context menu: http://jetyi.blog.sohu.com/album/photosetview-46937434-13489242.html 以下两个图像是我的快捷菜单和完整的外壳上下文菜单: http : //jetyi.blog.sohu.com/album/photosetview-46937434-13489242.html

You see, the 2end one is full shortcut menu and the 1st one is my obtaining shortcut menu by the code. 您会看到,第2个是完整的快捷菜单,第一个是我通过代码获取的快捷菜单。 Why they are different, who can resolve this problem? 为什么它们不同,谁能解决这个问题?

For resolve this problem, I debug the shell with my shortcut extension project, I find some useful information. 为了解决此问题,我使用快捷方式扩展项目调试了外壳,发现了一些有用的信息。 Following is the code-1: 以下是代码1:

...
psf->GetUIObjectOf(hParentWnd, 1, (LPCITEMIDLIST*)&pdilChild, IID_IContextMenu, NULL, (LPVOID*)&pcm);
pcm->QueryInterface(IID_IContextMenu3, (LPVOID*)&pcm3);
pcm3->QueryContextMenu(hMenu, 0, 1, 50000, dwFlags);
...

Code-1 can obtain a full context menu(the 3nd image) of user's selecting item in folder specified by 'psf'(IShellFolder*). 代码1可以在“ psf”(IShellFolder *)指定的文件夹中获得用户选择项的完整上下文菜单(第三个图像)。 My VS2008 statck show thes informations: 我的VS2008 statck显示这些信息:

ShortcutMenuShellEx.dll!CShellExInit::Initialize(...)
shell32.dll!_HDXA_AppendMenuItems2@36()  - 0x14b bytes  
shell32.dll!CDefFolderMenu::QueryContextMenu()  + 0x2c1 bytes   
shell32.dll!CContextMenuOnContextMenuArray::QueryContextMenu()  + 0x7d bytes    
shell32.dll!CDefView::_DoContextMenuPopup()  + 0xfb bytes   
shell32.dll!CDefView::ContextMenu()  + 0x1e4 bytes  
shell32.dll!CDefView::WndProc()  + 0xf2bc bytes 
shell32.dll!CDefView::s_WndProc()  + 0x56 bytes 
user32.dll!_InternalCallWinProc@20()  + 0x28 bytes  
...

But, using the forename code: 但是,使用姓氏代码:

...
pShellView->GetItemObject(SVGIO_BACKGROUND, IID_IContextMenu3, (LPVOID*)&pcm3);
...

It obtains the short context menu (the 1st image). 它获得短上下文菜单(第一张图像)。 My VS2008 stack shows these informations: 我的VS2008堆栈显示以下信息:

ShortcutMenuShellEx.dll!CShellExInit::Initialize(...)
shell32.dll!_HDXA_AppendMenuItems2@36()  - 0x14b bytes  
shell32.dll!CDefFolderMenu::QueryContextMenu()  + 0x2c1 bytes   
shell32.dll!CContextMenuOnContextMenuArray::QueryContextMenu()  + 0x7d bytes    
user32.dll!_InternalCallWinProc@20()  + 0x28 bytes  
...

I can not find CDefView::xxx , is it that caused the problem? 我找不到CDefView::xxx ,是引起问题的原因吗?

You will need to study the following example. 您将需要研究以下示例。 I assure you, it is extremely difficult to get your head around unless you work with the shell all the time. 我向您保证,除非您一直使用shell,否则很难动手。

How to host an IContextMenu http://blogs.msdn.com/b/oldnewthing/archive/2004/09/20/231739.aspx 如何托管IContextMenu http://blogs.msdn.com/b/oldnewthing/archive/2004/09/20/231739.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Qt Creator中编辑QtWebKit的右键单击上下文菜单? - How to edit QtWebKit's right-click context menu in Qt Creator? 如何在列表控件中创建右键菜单? - How do I create a right-click menu in a list control? 如何通过编程将命令添加到某些扩展名的右键菜单? - How to add command to right-click menu of certain extension programmatically? 以编程方式为多个文件调用Windows shell菜单(与在资源管理器中右键单击相同) - Calling Windows shell menu (same as right-click in Explorer) for multiple files programmatically 是否可以通过编程方式将项目添加到Mac OS的右键单击上下文菜单中? - Is it possible to add an item to the right-click context menu of a Mac OS programmatically? 如何在 QGraphicsView 中为右键单击创建上下文菜单 - How to create a context menu for right click in QGraphicsView 如何在列表框上右键单击创建上下文菜单? - How to create a context menu on listbox right click? 从Shell扩展将项目插入桌面右键菜单 - Insert item to desktop right-click menufrom shell extension MFC - 右键单击弹出菜单旁边缺少图标 - MFC - Missing Icons next to Right-Click Popup Menu MSVC 2010:输入期间允许在控制台中单击右键菜单 - MSVC 2010: Allow right-click menu in console during input
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM