Question

I am developing a windows-explorer type application, in that I am trying to invoke IContextMenu operations like copy, paste, properties, delete etc, but only copy and cut operation is not accomplishing whereas as they are invoking successfully.

Please see below scenario;

I am setting CMINVOKECOMMANDINFO.lpVerb to respective command string ("copy", "paste", "properties" etc).

CMINVOKECOMMANDINFO cmici={ sizeof(CMINVOKECOMMANDINFO) };
ZeroMemory( &cmici, sizeof(CMINVOKECOMMANDINFO));
cmici.cbSize = sizeof(CMINVOKECOMMANDINFO);
cmici.fMask=0;
cmici.hwnd=m_pOwnerWnd!=NULL ? m_pOwnerWnd->GetSafeHwnd() : NULL;
cmici.lpVerb= "copy";
cmici.lpParameters= NULL;
cmici.lpDirectory=NULL;
cmici.nShow=SW_SHOWNORMAL;
cmici.dwHotKey=0;
cmici.hIcon=NULL;

Fetching ITEMIDLIST's contextmenu;

HRESULT hResult = lpParentFolder->GetUIObjectOf(
  m_pOwnerWnd!=NULL ? m_pOwnerWnd->GetSafeHwnd() : NULL, 1,
  (const struct _ITEMIDLIST**)&(lpRelativeIDL), IID_IContextMenu, 0,
  (LPVOID*)&lpcm)

Querying contextmenu;

hResult=lpcm->QueryContextMenu(hMenu,0,1,0x7fff,dwFlags);

Finally invoking;

    hResult=lpcm->InvokeCommand(&cmici);

::DestroyMenu(hMenu);

lpcm->Release();

if(FAILED(hResult))  
    return FALSE;

return TRUE;

Command delete, properties, paste etc. are working fine except copy and cut

Please could any one help me in this regard?

Thanks.

Was it helpful?

Solution

Same issue is mentioned at this link under heading OleInitialize.

I moved the call to OleInitialize() to the form’s OnCreate event handler, and Cut / Copy menu items began working.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top