Author: janderwald Date: Wed Oct 29 11:00:28 2008 New Revision: 37063
URL: http://svn.reactos.org/svn/reactos?rev=37063&view=rev Log: * Try to invoke items by executing the default context menu action * Fixes executing of items like network connections folder whose items are no file system objects * Colin's wish list (1/2) :)
Modified: trunk/reactos/dll/win32/shell32/shlview.c
Modified: trunk/reactos/dll/win32/shell32/shlview.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shlview.c... ============================================================================== --- trunk/reactos/dll/win32/shell32/shlview.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/shlview.c [iso-8859-1] Wed Oct 29 11:00:28 2008 @@ -835,6 +835,8 @@ static UINT CF_IDLIST = 0; HRESULT hr; IDataObject* selection; + IContextMenu * cm; + HMENU hmenu; FORMATETC fetc; STGMEDIUM stgm; LPIDA pIDList; @@ -843,14 +845,68 @@ LPCWSTR parent_dir = NULL; SFGAOF attribs; int i; + CMINVOKECOMMANDINFOEX ici; + MENUITEMINFOW info;
if (0 == ShellView_GetSelections(This)) { return S_OK; } + + hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, + (LPCITEMIDLIST*)This->apidl, &IID_IContextMenu, + 0, (LPVOID *)&cm); + + if (SUCCEEDED(hr)) + { + hmenu = CreatePopupMenu(); + if (hmenu) + { + if (SUCCEEDED(IContextMenu_QueryContextMenu( cm, hmenu, 0, 0x20, 0x7fff, CMF_DEFAULTONLY))) + { + INT def = -1, n = GetMenuItemCount(hmenu); + + for ( i = 0; i < n; i++ ) + { + memset( &info, 0, sizeof info ); + info.cbSize = sizeof info; + info.fMask = MIIM_FTYPE | MIIM_STATE | MIIM_ID; + if (GetMenuItemInfoW( hmenu, i, TRUE, &info)) + { + if (info.fState & MFS_DEFAULT) + { + def = info.wID; + break; + } + } + } + if (def != -1) + { + memset( &ici, 0, sizeof ici ); + ici.cbSize = sizeof ici; + ici.lpVerb = MAKEINTRESOURCEA( def ); + ici.hwnd = This->hWnd; + + IContextMenu_InvokeCommand(cm, (LPCMINVOKECOMMANDINFO) &ici ); + IContextMenu_Release(cm); + DestroyMenu( hmenu ); + return S_OK; + } + + } + DestroyMenu( hmenu ); + } + IContextMenu_Release(cm); + } + + + hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, &IID_IDataObject, 0, (LPVOID *)&selection); + + + if (FAILED(hr)) return hr;