Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

2000 desktop namespace crashes on InvokeCommand(CMDSTR_NEWFOLDER)?

22 views
Skip to first unread message

Mike Scanlon

unread,
Apr 2, 2002, 11:06:09 AM4/2/02
to
I implemented a custom file dialog class under NT 4.0, which used the
following code to implement the new folder button:

IShellView *pView = GetShellBrowser()->GetActiveSV();
if(pView)
{
IContextMenu *pCtx = NULL;

if(SUCCEEDED(pView->GetItemObject(SVGIO_BACKGROUND,IID_IContextMenu,(void**)
&pCtx)))
{
CMINVOKECOMMANDINFO ci;
ZeroMemory(&ci,sizeof(CMINVOKECOMMANDINFO));
ci.cbSize = sizeof(CMINVOKECOMMANDINFO);
ci.hwnd = m_hWnd;
ci.lpVerb = CMDSTR_NEWFOLDERA;

pCtx->InvokeCommand(&ci);
pCtx->Release();
pCtx = NULL;
}
}

Under Windows 2000, this code crashes on the call to InvokeCommand. Anyone
have an idea what may be going on? Changing the CMINVOKECOMMANDINFO's to
EX's and using the unicode command strings still crashes.

Thanks,
Mike Scanlon
mike_s...@ibi.com


Chris Guzak [MS]

unread,
Apr 3, 2002, 12:37:30 AM4/3/02
to
you need to call QueryContextMenu first. the protocol for use of IContextMenus requires this.
 
some code like this...
 
STDAPI SHInvokeCommand(HWND hwnd, IShellFolder* psf, LPCITEMIDLIST pidlItem, LPCSTR pszVerb)
{
    IContextMenu *pcm;
    HRESULT hr = psf->GetUIObjectOf(hwnd, 1, &pidlItem, IID_X_PPV_ARG(IContextMenu, 0, &pcm));
    if (SUCCEEDED(hr))
    {
        hr = SHInvokeCommandsOnContextMenu(hwnd, NULL, pcm, 0, pszVerb);
        pcm->Release();
    }
    return hr;
}
 
STDAPI SHInvokeCommandsOnContextMenu(HWND hwnd, IUnknown* punk, IContextMenu *pcm, DWORD fMask, LPCSTR pszVerb)
{
    HRESULT hr = E_OUTOFMEMORY;
 
    HMENU hmenu = CreatePopupMenu();
    if (hmenu)
    {
        hr = pcm->QueryContextMenu(hmenu, 0, CONTEXTMENU_IDCMD_FIRST, CONTEXTMENU_IDCMD_LAST, 0);
        if (SUCCEEDED(hr))
        {
            CMINVOKECOMMANDINFOEX ici = { 0 };
 
            ici.cbSize = sizeof(ici);
            ici.fMask = fMask;
            ici.hwnd = hwnd;
            ici.lpVerb = pszVerb;
            ici.nShow = SW_NORMAL;
 
            hr = pcm->InvokeCommand((LPCMINVOKECOMMANDINFO)&ici);
        }
 
        DestroyMenu(hmenu);
    }
 
    return hr;
}
 
"Mike Scanlon" <mike_s...@ibi.com> wrote in message news:3ca9d44d$1...@news1.ibi.com...
0 new messages