I can get the IShellView shell IShellView , and I can get its context menu by right-clicking on the white area of ββthe folder (background), the following is my code:
... 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 of the following images are my context menu and the full shell context menu: http://jetyi.blog.sohu.com/album/photosetview-46937434-13489242.html
You see that 2end is the full context menu, and the first is my receipt of the context menu by code. Why are they different, who can solve this problem?
To solve this problem, I debug the shell with my shortcut extension project, I find useful information. Below is code-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 get the full context menu (3rd image) of the user selecting an item in the folder indicated by "psf" (IShellFolder *). My VS2008 statistics show data:
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 name code:
... pShellView->GetItemObject(SVGIO_BACKGROUND, IID_IContextMenu3, (LPVOID*)&pcm3); ...
Gets a short context menu (first image). My VS2008 stack shows this data:
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 , did this cause a problem?