1999-04-01 12:24:21 +02:00
|
|
|
/*
|
1999-05-17 17:33:54 +02:00
|
|
|
* see www.geocities.com/SiliconValley/4942/filemenu.html
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* Copyright 1999, 2000 Juergen Schmied
|
2011-08-03 23:42:17 +02:00
|
|
|
* Copyright 2011 Jay Yang
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1999-04-01 12:24:21 +02:00
|
|
|
*/
|
2002-03-10 00:29:33 +01:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1999-04-01 12:24:21 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2001-11-06 23:31:19 +01:00
|
|
|
#include "winreg.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2000-09-26 02:00:55 +02:00
|
|
|
#include "shlobj.h"
|
2001-08-16 20:49:56 +02:00
|
|
|
#include "undocshell.h"
|
2001-01-07 22:50:52 +01:00
|
|
|
#include "shlwapi.h"
|
1999-04-01 12:24:21 +02:00
|
|
|
#include "shell32_main.h"
|
|
|
|
|
|
|
|
#include "pidl.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2011-08-03 23:42:17 +02:00
|
|
|
#include "debughlp.h"
|
1999-04-01 12:24:21 +02:00
|
|
|
|
2004-10-19 05:56:40 +02:00
|
|
|
#ifdef FM_SEPARATOR
|
|
|
|
#undef FM_SEPARATOR
|
|
|
|
#endif
|
|
|
|
#define FM_SEPARATOR (LPCWSTR)1
|
|
|
|
|
|
|
|
static BOOL FileMenu_AppendItemW(HMENU hMenu, LPCWSTR lpText, UINT uID, int icon,
|
2001-07-24 01:50:18 +02:00
|
|
|
HMENU hMenuPopup, int nItemHeight);
|
1999-05-17 17:33:54 +02:00
|
|
|
|
|
|
|
typedef struct
|
1999-10-13 14:28:25 +02:00
|
|
|
{
|
|
|
|
BOOL bInitialized;
|
|
|
|
BOOL bFixedItems;
|
1999-05-17 17:33:54 +02:00
|
|
|
/* create */
|
|
|
|
COLORREF crBorderColor;
|
|
|
|
int nBorderWidth;
|
|
|
|
HBITMAP hBorderBmp;
|
|
|
|
|
|
|
|
/* insert using pidl */
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
UINT uID;
|
|
|
|
UINT uFlags;
|
|
|
|
UINT uEnumFlags;
|
|
|
|
LPFNFMCALLBACK lpfnCallback;
|
|
|
|
} FMINFO, *LPFMINFO;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{ int cchItemText;
|
|
|
|
int iIconIndex;
|
|
|
|
HMENU hMenu;
|
2004-10-19 05:56:40 +02:00
|
|
|
WCHAR szItemText[1];
|
1999-05-17 17:33:54 +02:00
|
|
|
} FMITEM, * LPFMITEM;
|
|
|
|
|
|
|
|
static BOOL bAbortInit;
|
|
|
|
|
|
|
|
#define CCH_MAXITEMTEXT 256
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2005-06-20 12:30:15 +02:00
|
|
|
static LPFMINFO FM_GetMenuInfo(HMENU hmenu)
|
|
|
|
{
|
|
|
|
MENUINFO MenuInfo;
|
1999-05-17 17:33:54 +02:00
|
|
|
LPFMINFO menudata;
|
|
|
|
|
|
|
|
MenuInfo.cbSize = sizeof(MENUINFO);
|
|
|
|
MenuInfo.fMask = MIM_MENUDATA;
|
|
|
|
|
|
|
|
if (! GetMenuInfo(hmenu, &MenuInfo))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
menudata = (LPFMINFO)MenuInfo.dwMenuData;
|
|
|
|
|
2000-01-04 01:33:56 +01:00
|
|
|
if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO)))
|
|
|
|
{
|
2006-10-07 20:18:14 +02:00
|
|
|
ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize);
|
2000-01-04 01:33:56 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
return menudata;
|
|
|
|
|
|
|
|
}
|
|
|
|
/*************************************************************************
|
|
|
|
* FM_SetMenuParameter [internal]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static LPFMINFO FM_SetMenuParameter(
|
|
|
|
HMENU hmenu,
|
|
|
|
UINT uID,
|
|
|
|
LPCITEMIDLIST pidl,
|
|
|
|
UINT uFlags,
|
|
|
|
UINT uEnumFlags,
|
|
|
|
LPFNFMCALLBACK lpfnCallback)
|
|
|
|
{
|
|
|
|
LPFMINFO menudata;
|
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
menudata = FM_GetMenuInfo(hmenu);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-10-07 03:06:26 +02:00
|
|
|
SHFree(menudata->pidl);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
menudata->uID = uID;
|
|
|
|
menudata->pidl = ILClone(pidl);
|
|
|
|
menudata->uFlags = uFlags;
|
|
|
|
menudata->uEnumFlags = uEnumFlags;
|
|
|
|
menudata->lpfnCallback = lpfnCallback;
|
|
|
|
|
|
|
|
return menudata;
|
|
|
|
}
|
1999-04-01 12:24:21 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* FM_InitMenuPopup [internal]
|
|
|
|
*
|
|
|
|
*/
|
2003-09-02 03:01:06 +02:00
|
|
|
static int FM_InitMenuPopup(HMENU hmenu, LPCITEMIDLIST pAlternatePidl)
|
1999-05-17 17:33:54 +02:00
|
|
|
{ IShellFolder *lpsf, *lpsf2;
|
2000-06-02 01:25:44 +02:00
|
|
|
ULONG ulItemAttr = SFGAO_FOLDER;
|
2008-04-24 22:43:56 +02:00
|
|
|
UINT uID, uEnumFlags;
|
1999-05-17 17:33:54 +02:00
|
|
|
LPFNFMCALLBACK lpfnCallback;
|
2003-09-02 03:01:06 +02:00
|
|
|
LPCITEMIDLIST pidl;
|
2004-10-19 05:56:40 +02:00
|
|
|
WCHAR sTemp[MAX_PATH];
|
1999-05-17 17:33:54 +02:00
|
|
|
int NumberOfItems = 0, iIcon;
|
|
|
|
MENUINFO MenuInfo;
|
|
|
|
LPFMINFO menudata;
|
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p %p\n", hmenu, pAlternatePidl);
|
1999-05-17 17:33:54 +02:00
|
|
|
|
|
|
|
MenuInfo.cbSize = sizeof(MENUINFO);
|
|
|
|
MenuInfo.fMask = MIM_MENUDATA;
|
|
|
|
|
|
|
|
if (! GetMenuInfo(hmenu, &MenuInfo))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
menudata = (LPFMINFO)MenuInfo.dwMenuData;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-01-04 01:33:56 +01:00
|
|
|
if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO)))
|
|
|
|
{
|
2006-10-07 20:18:14 +02:00
|
|
|
ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize);
|
2000-01-04 01:33:56 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
if (menudata->bInitialized)
|
|
|
|
return 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-09-02 03:01:06 +02:00
|
|
|
pidl = (pAlternatePidl? pAlternatePidl: menudata->pidl);
|
1999-10-13 14:28:25 +02:00
|
|
|
if (!pidl)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
uID = menudata->uID;
|
1999-05-17 17:33:54 +02:00
|
|
|
uEnumFlags = menudata->uEnumFlags;
|
|
|
|
lpfnCallback = menudata->lpfnCallback;
|
|
|
|
menudata->bInitialized = FALSE;
|
1999-10-13 14:28:25 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
SetMenuInfo(hmenu, &MenuInfo);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
if (SUCCEEDED (SHGetDesktopFolder(&lpsf)))
|
|
|
|
{
|
2009-08-29 14:23:42 +02:00
|
|
|
if (SUCCEEDED(IShellFolder_BindToObject(lpsf, pidl,0,&IID_IShellFolder,(LPVOID *)&lpsf2)))
|
1999-05-17 17:33:54 +02:00
|
|
|
{
|
|
|
|
IEnumIDList *lpe = NULL;
|
|
|
|
|
|
|
|
if (SUCCEEDED (IShellFolder_EnumObjects(lpsf2, 0, uEnumFlags, &lpe )))
|
|
|
|
{
|
|
|
|
|
|
|
|
LPITEMIDLIST pidlTemp = NULL;
|
|
|
|
ULONG ulFetched;
|
|
|
|
|
2012-01-08 01:31:54 +01:00
|
|
|
while ((!bAbortInit) && (S_OK == IEnumIDList_Next(lpe,1,&pidlTemp,&ulFetched)))
|
1999-05-17 17:33:54 +02:00
|
|
|
{
|
2003-09-02 03:01:06 +02:00
|
|
|
if (SUCCEEDED (IShellFolder_GetAttributesOf(lpsf, 1, (LPCITEMIDLIST*)&pidlTemp, &ulItemAttr)))
|
1999-05-17 17:33:54 +02:00
|
|
|
{
|
2004-10-19 05:56:40 +02:00
|
|
|
ILGetDisplayNameExW(NULL, pidlTemp, sTemp, ILGDN_FORPARSING);
|
2000-02-26 19:48:16 +01:00
|
|
|
if (! (PidlToSicIndex(lpsf, pidlTemp, FALSE, 0, &iIcon)))
|
1999-05-17 17:33:54 +02:00
|
|
|
iIcon = FM_BLANK_ICON;
|
|
|
|
if ( SFGAO_FOLDER & ulItemAttr)
|
|
|
|
{
|
|
|
|
LPFMINFO lpFmMi;
|
|
|
|
MENUINFO MenuInfo;
|
|
|
|
HMENU hMenuPopup = CreatePopupMenu();
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
lpFmMi = heap_alloc_zero(sizeof(*lpFmMi));
|
1999-05-17 17:33:54 +02:00
|
|
|
|
|
|
|
lpFmMi->pidl = ILCombine(pidl, pidlTemp);
|
|
|
|
lpFmMi->uEnumFlags = SHCONTF_FOLDERS | SHCONTF_NONFOLDERS;
|
|
|
|
|
|
|
|
MenuInfo.cbSize = sizeof(MENUINFO);
|
|
|
|
MenuInfo.fMask = MIM_MENUDATA;
|
2005-09-02 13:32:17 +02:00
|
|
|
MenuInfo.dwMenuData = (ULONG_PTR) lpFmMi;
|
1999-05-17 17:33:54 +02:00
|
|
|
SetMenuInfo (hMenuPopup, &MenuInfo);
|
|
|
|
|
2004-10-19 05:56:40 +02:00
|
|
|
FileMenu_AppendItemW (hmenu, sTemp, uID, iIcon, hMenuPopup, FM_DEFAULT_HEIGHT);
|
1999-05-17 17:33:54 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-10-19 05:56:40 +02:00
|
|
|
LPWSTR pExt = PathFindExtensionW(sTemp);
|
|
|
|
if (pExt)
|
|
|
|
*pExt = 0;
|
|
|
|
FileMenu_AppendItemW (hmenu, sTemp, uID, iIcon, 0, FM_DEFAULT_HEIGHT);
|
1999-05-17 17:33:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpfnCallback)
|
|
|
|
{
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("enter callback\n");
|
1999-05-17 17:33:54 +02:00
|
|
|
lpfnCallback ( pidl, pidlTemp);
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("leave callback\n");
|
1999-05-17 17:33:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
NumberOfItems++;
|
|
|
|
}
|
|
|
|
IEnumIDList_Release (lpe);
|
|
|
|
}
|
|
|
|
IShellFolder_Release(lpsf2);
|
|
|
|
}
|
|
|
|
IShellFolder_Release(lpsf);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( GetMenuItemCount (hmenu) == 0 )
|
2004-10-19 05:56:40 +02:00
|
|
|
{
|
2021-09-20 12:58:52 +02:00
|
|
|
FileMenu_AppendItemW (hmenu, L"(empty)", uID, FM_BLANK_ICON, 0, FM_DEFAULT_HEIGHT);
|
1999-07-10 13:56:34 +02:00
|
|
|
NumberOfItems++;
|
|
|
|
}
|
1999-05-17 17:33:54 +02:00
|
|
|
|
|
|
|
menudata->bInitialized = TRUE;
|
|
|
|
SetMenuInfo(hmenu, &MenuInfo);
|
|
|
|
|
|
|
|
return NumberOfItems;
|
|
|
|
}
|
1999-04-01 12:24:21 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_Create [SHELL32.114]
|
|
|
|
*
|
1999-10-13 14:28:25 +02:00
|
|
|
* NOTES
|
|
|
|
* for non-root menus values are
|
2002-06-01 01:06:46 +02:00
|
|
|
* (ffffffff,00000000,00000000,00000000,00000000)
|
1999-04-01 12:24:21 +02:00
|
|
|
*/
|
|
|
|
HMENU WINAPI FileMenu_Create (
|
|
|
|
COLORREF crBorderColor,
|
|
|
|
int nBorderWidth,
|
|
|
|
HBITMAP hBorderBmp,
|
|
|
|
int nSelHeight,
|
|
|
|
UINT uFlags)
|
|
|
|
{
|
1999-05-17 17:33:54 +02:00
|
|
|
MENUINFO MenuInfo;
|
|
|
|
LPFMINFO menudata;
|
1999-04-01 12:24:21 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
HMENU hMenu = CreatePopupMenu();
|
1999-04-01 12:24:21 +02:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("0x%08x 0x%08x %p 0x%08x 0x%08x hMenu=%p\n",
|
1999-05-17 17:33:54 +02:00
|
|
|
crBorderColor, nBorderWidth, hBorderBmp, nSelHeight, uFlags, hMenu);
|
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
menudata = heap_alloc_zero(sizeof(*menudata));
|
1999-05-17 17:33:54 +02:00
|
|
|
menudata->crBorderColor = crBorderColor;
|
|
|
|
menudata->nBorderWidth = nBorderWidth;
|
|
|
|
menudata->hBorderBmp = hBorderBmp;
|
|
|
|
|
|
|
|
MenuInfo.cbSize = sizeof(MENUINFO);
|
|
|
|
MenuInfo.fMask = MIM_MENUDATA;
|
2005-09-02 13:32:17 +02:00
|
|
|
MenuInfo.dwMenuData = (ULONG_PTR) menudata;
|
1999-05-17 17:33:54 +02:00
|
|
|
SetMenuInfo (hMenu, &MenuInfo);
|
|
|
|
|
|
|
|
return hMenu;
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_Destroy [SHELL32.118]
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* exported by name
|
|
|
|
*/
|
1999-05-17 17:33:54 +02:00
|
|
|
void WINAPI FileMenu_Destroy (HMENU hmenu)
|
1999-04-01 12:24:21 +02:00
|
|
|
{
|
1999-05-17 17:33:54 +02:00
|
|
|
LPFMINFO menudata;
|
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p\n", hmenu);
|
1999-05-17 17:33:54 +02:00
|
|
|
|
|
|
|
FileMenu_DeleteAllItems (hmenu);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
menudata = FM_GetMenuInfo(hmenu);
|
|
|
|
|
2006-10-07 03:06:26 +02:00
|
|
|
SHFree( menudata->pidl);
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(menudata);
|
1999-05-17 17:33:54 +02:00
|
|
|
|
|
|
|
DestroyMenu (hmenu);
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* FileMenu_AppendItem [SHELL32.115]
|
1999-04-01 12:24:21 +02:00
|
|
|
*
|
|
|
|
*/
|
2004-10-19 05:56:40 +02:00
|
|
|
static BOOL FileMenu_AppendItemW(
|
1999-04-01 12:24:21 +02:00
|
|
|
HMENU hMenu,
|
2004-10-19 05:56:40 +02:00
|
|
|
LPCWSTR lpText,
|
1999-04-01 12:24:21 +02:00
|
|
|
UINT uID,
|
|
|
|
int icon,
|
|
|
|
HMENU hMenuPopup,
|
|
|
|
int nItemHeight)
|
|
|
|
{
|
2004-10-19 05:56:40 +02:00
|
|
|
MENUITEMINFOW mii;
|
1999-10-13 14:28:25 +02:00
|
|
|
LPFMITEM myItem;
|
|
|
|
LPFMINFO menudata;
|
|
|
|
MENUINFO MenuInfo;
|
|
|
|
|
1999-04-01 12:24:21 +02:00
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p %s 0x%08x 0x%08x %p 0x%08x\n",
|
2004-10-19 05:56:40 +02:00
|
|
|
hMenu, (lpText!=FM_SEPARATOR) ? debugstr_w(lpText) : NULL,
|
|
|
|
uID, icon, hMenuPopup, nItemHeight);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-10-19 05:56:40 +02:00
|
|
|
ZeroMemory (&mii, sizeof(MENUITEMINFOW));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-10-19 05:56:40 +02:00
|
|
|
mii.cbSize = sizeof(MENUITEMINFOW);
|
1999-05-17 17:33:54 +02:00
|
|
|
|
|
|
|
if (lpText != FM_SEPARATOR)
|
2004-10-19 05:56:40 +02:00
|
|
|
{
|
2021-09-17 17:16:11 +02:00
|
|
|
int len = lstrlenW (lpText);
|
2008-11-05 23:00:50 +01:00
|
|
|
myItem = SHAlloc(sizeof(FMITEM) + len*sizeof(WCHAR));
|
2021-09-17 17:16:11 +02:00
|
|
|
lstrcpyW (myItem->szItemText, lpText);
|
1999-05-17 17:33:54 +02:00
|
|
|
myItem->cchItemText = len;
|
|
|
|
myItem->iIconIndex = icon;
|
|
|
|
myItem->hMenu = hMenu;
|
|
|
|
mii.fMask = MIIM_DATA;
|
2005-09-02 13:32:17 +02:00
|
|
|
mii.dwItemData = (ULONG_PTR) myItem;
|
1999-05-17 17:33:54 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-04-01 12:24:21 +02:00
|
|
|
if ( hMenuPopup )
|
|
|
|
{ /* sub menu */
|
1999-05-17 17:33:54 +02:00
|
|
|
mii.fMask |= MIIM_TYPE | MIIM_SUBMENU;
|
|
|
|
mii.fType = MFT_OWNERDRAW;
|
1999-04-01 12:24:21 +02:00
|
|
|
mii.hSubMenu = hMenuPopup;
|
|
|
|
}
|
|
|
|
else if (lpText == FM_SEPARATOR )
|
1999-05-17 17:33:54 +02:00
|
|
|
{ mii.fMask |= MIIM_ID | MIIM_TYPE;
|
1999-04-01 12:24:21 +02:00
|
|
|
mii.fType = MFT_SEPARATOR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* normal item */
|
1999-05-17 17:33:54 +02:00
|
|
|
mii.fMask |= MIIM_ID | MIIM_TYPE | MIIM_STATE;
|
1999-04-01 12:24:21 +02:00
|
|
|
mii.fState = MFS_ENABLED | MFS_DEFAULT;
|
1999-05-17 17:33:54 +02:00
|
|
|
mii.fType = MFT_OWNERDRAW;
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
mii.wID = uID;
|
|
|
|
|
2004-10-19 05:56:40 +02:00
|
|
|
InsertMenuItemW (hMenu, (UINT)-1, TRUE, &mii);
|
1999-04-01 12:24:21 +02:00
|
|
|
|
1999-10-13 14:28:25 +02:00
|
|
|
/* set bFixedItems to true */
|
|
|
|
MenuInfo.cbSize = sizeof(MENUINFO);
|
|
|
|
MenuInfo.fMask = MIM_MENUDATA;
|
|
|
|
|
|
|
|
if (! GetMenuInfo(hMenu, &MenuInfo))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
menudata = (LPFMINFO)MenuInfo.dwMenuData;
|
2000-01-04 01:33:56 +01:00
|
|
|
if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO)))
|
|
|
|
{
|
2006-10-07 20:18:14 +02:00
|
|
|
ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize);
|
2013-01-10 19:54:34 +01:00
|
|
|
return FALSE;
|
2000-01-04 01:33:56 +01:00
|
|
|
}
|
|
|
|
|
1999-10-13 14:28:25 +02:00
|
|
|
menudata->bFixedItems = TRUE;
|
|
|
|
SetMenuInfo(hMenu, &MenuInfo);
|
|
|
|
|
1999-04-01 12:24:21 +02:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
}
|
2000-12-02 00:58:28 +01:00
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
BOOL WINAPI FileMenu_AppendItemAW(
|
|
|
|
HMENU hMenu,
|
|
|
|
LPCVOID lpText,
|
|
|
|
UINT uID,
|
|
|
|
int icon,
|
|
|
|
HMENU hMenuPopup,
|
|
|
|
int nItemHeight)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
2009-12-01 23:14:10 +01:00
|
|
|
if (!lpText) return FALSE;
|
|
|
|
|
|
|
|
if (SHELL_OsIsUnicode() || lpText == FM_SEPARATOR)
|
2004-10-19 05:56:40 +02:00
|
|
|
ret = FileMenu_AppendItemW(hMenu, lpText, uID, icon, hMenuPopup, nItemHeight);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD len = MultiByteToWideChar( CP_ACP, 0, lpText, -1, NULL, 0 );
|
2018-02-22 08:43:28 +01:00
|
|
|
LPWSTR lpszText = heap_alloc( len*sizeof(WCHAR) );
|
2009-12-01 23:14:10 +01:00
|
|
|
if (!lpszText) return FALSE;
|
2004-10-19 05:56:40 +02:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, lpText, -1, lpszText, len );
|
|
|
|
ret = FileMenu_AppendItemW(hMenu, lpszText, uID, icon, hMenuPopup, nItemHeight);
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free( lpszText );
|
2004-10-19 05:56:40 +02:00
|
|
|
}
|
1999-05-17 17:33:54 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2005-06-20 12:30:15 +02:00
|
|
|
|
1999-04-01 12:24:21 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_InsertUsingPidl [SHELL32.110]
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* uEnumFlags any SHCONTF flag
|
|
|
|
*/
|
|
|
|
int WINAPI FileMenu_InsertUsingPidl (
|
1999-05-17 17:33:54 +02:00
|
|
|
HMENU hmenu,
|
1999-04-01 12:24:21 +02:00
|
|
|
UINT uID,
|
|
|
|
LPCITEMIDLIST pidl,
|
|
|
|
UINT uFlags,
|
|
|
|
UINT uEnumFlags,
|
|
|
|
LPFNFMCALLBACK lpfnCallback)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p 0x%08x %p 0x%08x 0x%08x %p\n",
|
1999-05-17 17:33:54 +02:00
|
|
|
hmenu, uID, pidl, uFlags, uEnumFlags, lpfnCallback);
|
1999-04-01 12:24:21 +02:00
|
|
|
|
|
|
|
pdump (pidl);
|
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
bAbortInit = FALSE;
|
1999-04-01 12:24:21 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
FM_SetMenuParameter(hmenu, uID, pidl, uFlags, uEnumFlags, lpfnCallback);
|
1999-05-17 17:33:54 +02:00
|
|
|
|
|
|
|
return FM_InitMenuPopup(hmenu, NULL);
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_ReplaceUsingPidl [SHELL32.113]
|
|
|
|
*
|
2004-01-06 23:08:33 +01:00
|
|
|
* FIXME: the static items are deleted but won't be refreshed
|
1999-04-01 12:24:21 +02:00
|
|
|
*/
|
|
|
|
int WINAPI FileMenu_ReplaceUsingPidl(
|
1999-05-17 17:33:54 +02:00
|
|
|
HMENU hmenu,
|
1999-04-01 12:24:21 +02:00
|
|
|
UINT uID,
|
|
|
|
LPCITEMIDLIST pidl,
|
|
|
|
UINT uEnumFlags,
|
|
|
|
LPFNFMCALLBACK lpfnCallback)
|
|
|
|
{
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p 0x%08x %p 0x%08x %p\n",
|
1999-05-17 17:33:54 +02:00
|
|
|
hmenu, uID, pidl, uEnumFlags, lpfnCallback);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
FileMenu_DeleteAllItems (hmenu);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
FM_SetMenuParameter(hmenu, uID, pidl, 0, uEnumFlags, lpfnCallback);
|
1999-05-17 17:33:54 +02:00
|
|
|
|
|
|
|
return FM_InitMenuPopup(hmenu, NULL);
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_Invalidate [SHELL32.111]
|
|
|
|
*/
|
|
|
|
void WINAPI FileMenu_Invalidate (HMENU hMenu)
|
|
|
|
{
|
2002-11-22 00:56:42 +01:00
|
|
|
FIXME("%p\n",hMenu);
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_FindSubMenuByPidl [SHELL32.106]
|
|
|
|
*/
|
|
|
|
HMENU WINAPI FileMenu_FindSubMenuByPidl(
|
|
|
|
HMENU hMenu,
|
|
|
|
LPCITEMIDLIST pidl)
|
|
|
|
{
|
2002-11-22 00:56:42 +01:00
|
|
|
FIXME("%p %p\n",hMenu, pidl);
|
1999-04-01 12:24:21 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_AppendFilesForPidl [SHELL32.124]
|
|
|
|
*/
|
Complete cleanup, bugfixes.
New: PathStripPath, PathMakeUniqueName, PathStripToRoot,
PathGetShortPath, PathParseIconLocation, PathRemoveExtension,
PathRemoveArgs, PathAppend, PathBuildRoot, PathCanonicalize,
PathFindNextComponent, PathRemoveFileSpec.
2000-04-28 22:23:46 +02:00
|
|
|
int WINAPI FileMenu_AppendFilesForPidl(
|
1999-05-17 17:33:54 +02:00
|
|
|
HMENU hmenu,
|
1999-04-01 12:24:21 +02:00
|
|
|
LPCITEMIDLIST pidl,
|
2006-09-07 20:00:15 +02:00
|
|
|
BOOL bAddSeparator)
|
1999-04-01 12:24:21 +02:00
|
|
|
{
|
1999-05-17 17:33:54 +02:00
|
|
|
LPFMINFO menudata;
|
|
|
|
|
|
|
|
menudata = FM_GetMenuInfo(hmenu);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
menudata->bInitialized = FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
FM_InitMenuPopup(hmenu, pidl);
|
|
|
|
|
2006-09-07 20:00:15 +02:00
|
|
|
if (bAddSeparator)
|
2004-10-19 05:56:40 +02:00
|
|
|
FileMenu_AppendItemW (hmenu, FM_SEPARATOR, 0, 0, 0, FM_DEFAULT_HEIGHT);
|
1999-05-17 17:33:54 +02:00
|
|
|
|
2006-09-07 20:00:15 +02:00
|
|
|
TRACE("%p %p 0x%08x\n",hmenu, pidl,bAddSeparator);
|
1999-05-17 17:33:54 +02:00
|
|
|
|
1999-04-01 12:24:21 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_AddFilesForPidl [SHELL32.125]
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* uEnumFlags any SHCONTF flag
|
|
|
|
*/
|
|
|
|
int WINAPI FileMenu_AddFilesForPidl (
|
1999-05-17 17:33:54 +02:00
|
|
|
HMENU hmenu,
|
1999-04-01 12:24:21 +02:00
|
|
|
UINT uReserved,
|
|
|
|
UINT uID,
|
|
|
|
LPCITEMIDLIST pidl,
|
|
|
|
UINT uFlags,
|
|
|
|
UINT uEnumFlags,
|
|
|
|
LPFNFMCALLBACK lpfnCallback)
|
|
|
|
{
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p 0x%08x 0x%08x %p 0x%08x 0x%08x %p\n",
|
1999-05-17 17:33:54 +02:00
|
|
|
hmenu, uReserved, uID, pidl, uFlags, uEnumFlags, lpfnCallback);
|
|
|
|
|
|
|
|
return FileMenu_InsertUsingPidl ( hmenu, uID, pidl, uFlags, uEnumFlags, lpfnCallback);
|
1999-04-01 12:24:21 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_TrackPopupMenuEx [SHELL32.116]
|
|
|
|
*/
|
Complete cleanup, bugfixes.
New: PathStripPath, PathMakeUniqueName, PathStripToRoot,
PathGetShortPath, PathParseIconLocation, PathRemoveExtension,
PathRemoveArgs, PathAppend, PathBuildRoot, PathCanonicalize,
PathFindNextComponent, PathRemoveFileSpec.
2000-04-28 22:23:46 +02:00
|
|
|
BOOL WINAPI FileMenu_TrackPopupMenuEx (
|
1999-04-01 12:24:21 +02:00
|
|
|
HMENU hMenu,
|
|
|
|
UINT uFlags,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
HWND hWnd,
|
|
|
|
LPTPMPARAMS lptpm)
|
|
|
|
{
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p 0x%08x 0x%x 0x%x %p %p\n",
|
1999-04-01 12:24:21 +02:00
|
|
|
hMenu, uFlags, x, y, hWnd, lptpm);
|
|
|
|
return TrackPopupMenuEx(hMenu, uFlags, x, y, hWnd, lptpm);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_GetLastSelectedItemPidls [SHELL32.107]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI FileMenu_GetLastSelectedItemPidls(
|
|
|
|
UINT uReserved,
|
|
|
|
LPCITEMIDLIST *ppidlFolder,
|
|
|
|
LPCITEMIDLIST *ppidlItem)
|
|
|
|
{
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("0x%08x %p %p\n",uReserved, ppidlFolder, ppidlItem);
|
2013-01-10 19:54:34 +01:00
|
|
|
return FALSE;
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
#define FM_ICON_SIZE 16
|
|
|
|
#define FM_Y_SPACE 4
|
|
|
|
#define FM_SPACE1 4
|
|
|
|
#define FM_SPACE2 2
|
|
|
|
#define FM_LEFTBORDER 2
|
|
|
|
#define FM_RIGHTBORDER 8
|
1999-04-01 12:24:21 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_MeasureItem [SHELL32.112]
|
|
|
|
*/
|
|
|
|
LRESULT WINAPI FileMenu_MeasureItem(
|
|
|
|
HWND hWnd,
|
|
|
|
LPMEASUREITEMSTRUCT lpmis)
|
|
|
|
{
|
1999-05-17 17:33:54 +02:00
|
|
|
LPFMITEM pMyItem = (LPFMITEM)(lpmis->itemData);
|
|
|
|
HDC hdc = GetDC(hWnd);
|
|
|
|
SIZE size;
|
|
|
|
LPFMINFO menuinfo;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-10-19 05:56:40 +02:00
|
|
|
TRACE("%p %p %s\n", hWnd, lpmis, debugstr_w(pMyItem->szItemText));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-10-19 05:56:40 +02:00
|
|
|
GetTextExtentPoint32W(hdc, pMyItem->szItemText, pMyItem->cchItemText, &size);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
lpmis->itemWidth = size.cx + FM_LEFTBORDER + FM_ICON_SIZE + FM_SPACE1 + FM_SPACE2 + FM_RIGHTBORDER;
|
|
|
|
lpmis->itemHeight = (size.cy > (FM_ICON_SIZE + FM_Y_SPACE)) ? size.cy : (FM_ICON_SIZE + FM_Y_SPACE);
|
|
|
|
|
|
|
|
/* add the menubitmap */
|
|
|
|
menuinfo = FM_GetMenuInfo(pMyItem->hMenu);
|
1999-10-13 14:28:25 +02:00
|
|
|
if (menuinfo->nBorderWidth)
|
1999-05-17 17:33:54 +02:00
|
|
|
lpmis->itemWidth += menuinfo->nBorderWidth;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("-- 0x%04x 0x%04x\n", lpmis->itemWidth, lpmis->itemHeight);
|
1999-05-17 17:33:54 +02:00
|
|
|
ReleaseDC (hWnd, hdc);
|
1999-04-01 12:24:21 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_DrawItem [SHELL32.105]
|
|
|
|
*/
|
|
|
|
LRESULT WINAPI FileMenu_DrawItem(
|
|
|
|
HWND hWnd,
|
|
|
|
LPDRAWITEMSTRUCT lpdis)
|
|
|
|
{
|
1999-05-17 17:33:54 +02:00
|
|
|
LPFMITEM pMyItem = (LPFMITEM)(lpdis->itemData);
|
|
|
|
COLORREF clrPrevText, clrPrevBkgnd;
|
|
|
|
int xi,yi,xt,yt;
|
|
|
|
HIMAGELIST hImageList;
|
2008-04-24 22:43:56 +02:00
|
|
|
RECT TextRect;
|
1999-05-17 17:33:54 +02:00
|
|
|
LPFMINFO menuinfo;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-10-19 05:56:40 +02:00
|
|
|
TRACE("%p %p %s\n", hWnd, lpdis, debugstr_w(pMyItem->szItemText));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
if (lpdis->itemState & ODS_SELECTED)
|
|
|
|
{
|
|
|
|
clrPrevText = SetTextColor(lpdis->hDC, GetSysColor (COLOR_HIGHLIGHTTEXT));
|
|
|
|
clrPrevBkgnd = SetBkColor(lpdis->hDC, GetSysColor (COLOR_HIGHLIGHT));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
clrPrevText = SetTextColor(lpdis->hDC, GetSysColor (COLOR_MENUTEXT));
|
|
|
|
clrPrevBkgnd = SetBkColor(lpdis->hDC, GetSysColor (COLOR_MENU));
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2016-06-22 11:54:09 +02:00
|
|
|
TextRect = lpdis->rcItem;
|
1999-05-17 17:33:54 +02:00
|
|
|
|
|
|
|
/* add the menubitmap */
|
|
|
|
menuinfo = FM_GetMenuInfo(pMyItem->hMenu);
|
1999-10-13 14:28:25 +02:00
|
|
|
if (menuinfo->nBorderWidth)
|
1999-05-17 17:33:54 +02:00
|
|
|
TextRect.left += menuinfo->nBorderWidth;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
TextRect.left += FM_LEFTBORDER;
|
|
|
|
xi = TextRect.left + FM_SPACE1;
|
|
|
|
yi = TextRect.top + FM_Y_SPACE/2;
|
|
|
|
TextRect.bottom -= FM_Y_SPACE/2;
|
|
|
|
|
|
|
|
xt = xi + FM_ICON_SIZE + FM_SPACE2;
|
|
|
|
yt = yi;
|
|
|
|
|
2004-10-19 05:56:40 +02:00
|
|
|
ExtTextOutW (lpdis->hDC, xt , yt, ETO_OPAQUE, &TextRect, pMyItem->szItemText, pMyItem->cchItemText, NULL);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2010-07-20 10:11:49 +02:00
|
|
|
Shell_GetImageLists(0, &hImageList);
|
2001-01-17 23:05:24 +01:00
|
|
|
ImageList_Draw(hImageList, pMyItem->iIconIndex, lpdis->hDC, xi, yi, ILD_NORMAL);
|
1999-05-17 17:33:54 +02:00
|
|
|
|
2016-04-21 10:58:01 +02:00
|
|
|
TRACE("-- %s\n", wine_dbgstr_rect(&TextRect));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
SetTextColor(lpdis->hDC, clrPrevText);
|
|
|
|
SetBkColor(lpdis->hDC, clrPrevBkgnd);
|
|
|
|
|
|
|
|
return TRUE;
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_InitMenuPopup [SHELL32.109]
|
|
|
|
*
|
|
|
|
* NOTES
|
2005-03-23 14:15:18 +01:00
|
|
|
* The filemenu is an ownerdrawn menu. Call this function responding to
|
1999-04-01 12:24:21 +02:00
|
|
|
* WM_INITPOPUPMENU
|
|
|
|
*
|
|
|
|
*/
|
1999-05-17 17:33:54 +02:00
|
|
|
BOOL WINAPI FileMenu_InitMenuPopup (HMENU hmenu)
|
|
|
|
{
|
|
|
|
FM_InitMenuPopup(hmenu, NULL);
|
|
|
|
return TRUE;
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_HandleMenuChar [SHELL32.108]
|
|
|
|
*/
|
|
|
|
LRESULT WINAPI FileMenu_HandleMenuChar(
|
|
|
|
HMENU hMenu,
|
|
|
|
WPARAM wParam)
|
|
|
|
{
|
2007-05-24 16:41:17 +02:00
|
|
|
FIXME("%p 0x%08lx\n",hMenu,wParam);
|
1999-04-01 12:24:21 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_DeleteAllItems [SHELL32.104]
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* exported by name
|
|
|
|
*/
|
1999-05-17 17:33:54 +02:00
|
|
|
BOOL WINAPI FileMenu_DeleteAllItems (HMENU hmenu)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2004-10-19 05:56:40 +02:00
|
|
|
MENUITEMINFOW mii;
|
1999-05-17 17:33:54 +02:00
|
|
|
LPFMINFO menudata;
|
|
|
|
|
|
|
|
int i;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p\n", hmenu);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-10-19 05:56:40 +02:00
|
|
|
ZeroMemory ( &mii, sizeof(MENUITEMINFOW));
|
|
|
|
mii.cbSize = sizeof(MENUITEMINFOW);
|
1999-05-17 17:33:54 +02:00
|
|
|
mii.fMask = MIIM_SUBMENU|MIIM_DATA;
|
|
|
|
|
|
|
|
for (i = 0; i < GetMenuItemCount( hmenu ); i++)
|
2004-10-19 05:56:40 +02:00
|
|
|
{ GetMenuItemInfoW(hmenu, i, TRUE, &mii );
|
1999-05-17 17:33:54 +02:00
|
|
|
|
2006-10-07 03:06:26 +02:00
|
|
|
SHFree((LPFMINFO)mii.dwItemData);
|
1999-05-17 17:33:54 +02:00
|
|
|
|
|
|
|
if (mii.hSubMenu)
|
|
|
|
FileMenu_Destroy(mii.hSubMenu);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
while (DeleteMenu (hmenu, 0, MF_BYPOSITION)){};
|
|
|
|
|
|
|
|
menudata = FM_GetMenuInfo(hmenu);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-17 17:33:54 +02:00
|
|
|
menudata->bInitialized = FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-04-01 12:24:21 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* FileMenu_DeleteItemByCmd [SHELL32.117]
|
1999-04-01 12:24:21 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI FileMenu_DeleteItemByCmd (HMENU hMenu, UINT uID)
|
|
|
|
{
|
2004-10-19 05:56:40 +02:00
|
|
|
MENUITEMINFOW mii;
|
1999-05-17 17:33:54 +02:00
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p 0x%08x\n", hMenu, uID);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-10-19 05:56:40 +02:00
|
|
|
ZeroMemory ( &mii, sizeof(MENUITEMINFOW));
|
|
|
|
mii.cbSize = sizeof(MENUITEMINFOW);
|
1999-05-17 17:33:54 +02:00
|
|
|
mii.fMask = MIIM_SUBMENU;
|
|
|
|
|
2004-10-19 05:56:40 +02:00
|
|
|
GetMenuItemInfoW(hMenu, uID, FALSE, &mii );
|
2000-11-01 04:11:12 +01:00
|
|
|
if ( mii.hSubMenu )
|
|
|
|
{
|
|
|
|
/* FIXME: Do what? */
|
|
|
|
}
|
1999-04-01 12:24:21 +02:00
|
|
|
|
|
|
|
DeleteMenu(hMenu, MF_BYCOMMAND, uID);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_DeleteItemByIndex [SHELL32.140]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI FileMenu_DeleteItemByIndex ( HMENU hMenu, UINT uPos)
|
|
|
|
{
|
2004-10-19 05:56:40 +02:00
|
|
|
MENUITEMINFOW mii;
|
1999-05-17 17:33:54 +02:00
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p 0x%08x\n", hMenu, uPos);
|
1999-04-01 12:24:21 +02:00
|
|
|
|
2004-10-19 05:56:40 +02:00
|
|
|
ZeroMemory ( &mii, sizeof(MENUITEMINFOW));
|
|
|
|
mii.cbSize = sizeof(MENUITEMINFOW);
|
1999-05-17 17:33:54 +02:00
|
|
|
mii.fMask = MIIM_SUBMENU;
|
|
|
|
|
2004-10-19 05:56:40 +02:00
|
|
|
GetMenuItemInfoW(hMenu, uPos, TRUE, &mii );
|
2000-11-01 04:11:12 +01:00
|
|
|
if ( mii.hSubMenu )
|
|
|
|
{
|
|
|
|
/* FIXME: Do what? */
|
|
|
|
}
|
1999-05-17 17:33:54 +02:00
|
|
|
|
1999-04-01 12:24:21 +02:00
|
|
|
DeleteMenu(hMenu, MF_BYPOSITION, uPos);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_DeleteItemByFirstID [SHELL32.141]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI FileMenu_DeleteItemByFirstID(
|
|
|
|
HMENU hMenu,
|
|
|
|
UINT uID)
|
|
|
|
{
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p 0x%08x\n", hMenu, uID);
|
2013-01-10 19:54:34 +01:00
|
|
|
return FALSE;
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_DeleteSeparator [SHELL32.142]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI FileMenu_DeleteSeparator(HMENU hMenu)
|
|
|
|
{
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p\n", hMenu);
|
2013-01-10 19:54:34 +01:00
|
|
|
return FALSE;
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_EnableItemByCmd [SHELL32.143]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI FileMenu_EnableItemByCmd(
|
|
|
|
HMENU hMenu,
|
|
|
|
UINT uID,
|
|
|
|
BOOL bEnable)
|
|
|
|
{
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p 0x%08x 0x%08x\n", hMenu, uID,bEnable);
|
2013-01-10 19:54:34 +01:00
|
|
|
return FALSE;
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_GetItemExtent [SHELL32.144]
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
1999-05-17 17:33:54 +02:00
|
|
|
* NOTES
|
2001-11-06 22:01:32 +01:00
|
|
|
* if the menu is too big, entries are getting cut away!!
|
1999-04-01 12:24:21 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI FileMenu_GetItemExtent (HMENU hMenu, UINT uPos)
|
|
|
|
{ RECT rect;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
FIXME("%p 0x%08x\n", hMenu, uPos);
|
1999-04-01 12:24:21 +02:00
|
|
|
|
|
|
|
if (GetMenuItemRect(0, hMenu, uPos, &rect))
|
2016-04-21 10:58:01 +02:00
|
|
|
{
|
|
|
|
FIXME("%s\n", wine_dbgstr_rect(&rect));
|
1999-04-01 12:24:21 +02:00
|
|
|
return ((rect.right-rect.left)<<16) + (rect.top-rect.bottom);
|
|
|
|
}
|
2002-01-29 04:12:19 +01:00
|
|
|
return 0x00100010; /*FIXME*/
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FileMenu_AbortInitMenu [SHELL32.120]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void WINAPI FileMenu_AbortInitMenu (void)
|
1999-06-12 17:45:58 +02:00
|
|
|
{ TRACE("\n");
|
1999-05-17 17:33:54 +02:00
|
|
|
bAbortInit = TRUE;
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHFind_InitMenuPopup [SHELL32.149]
|
|
|
|
*
|
2005-11-10 12:15:22 +01:00
|
|
|
* Get the IContextMenu instance for the submenu of options displayed
|
|
|
|
* for the Search entry in the Classic style Start menu.
|
1999-04-01 12:24:21 +02:00
|
|
|
*
|
|
|
|
* PARAMETERS
|
1999-11-21 01:48:33 +01:00
|
|
|
* hMenu [in] handle of menu previously created
|
1999-04-01 12:24:21 +02:00
|
|
|
* hWndParent [in] parent window
|
1999-11-21 01:48:33 +01:00
|
|
|
* w [in] no pointer (0x209 over here) perhaps menu IDs ???
|
|
|
|
* x [in] no pointer (0x226 over here)
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* LPXXXXX pointer to struct containing a func addr at offset 8
|
|
|
|
* or NULL at failure.
|
1999-04-01 12:24:21 +02:00
|
|
|
*/
|
1999-11-21 01:48:33 +01:00
|
|
|
LPVOID WINAPI SHFind_InitMenuPopup (HMENU hMenu, HWND hWndParent, DWORD w, DWORD x)
|
2005-06-20 12:30:15 +02:00
|
|
|
{
|
2006-10-07 20:18:14 +02:00
|
|
|
FIXME("hmenu=%p hwnd=%p 0x%08x 0x%08x stub\n",
|
1999-04-01 12:24:21 +02:00
|
|
|
hMenu,hWndParent,w,x);
|
1999-11-21 01:48:33 +01:00
|
|
|
return NULL; /* this is supposed to be a pointer */
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2005-06-20 12:30:15 +02:00
|
|
|
* _SHIsMenuSeparator (internal)
|
1999-04-01 12:24:21 +02:00
|
|
|
*/
|
2005-06-20 12:30:15 +02:00
|
|
|
static BOOL _SHIsMenuSeparator(HMENU hm, int i)
|
1999-04-01 12:24:21 +02:00
|
|
|
{
|
2004-10-19 05:56:40 +02:00
|
|
|
MENUITEMINFOW mii;
|
1999-04-01 12:24:21 +02:00
|
|
|
|
2004-10-19 05:56:40 +02:00
|
|
|
mii.cbSize = sizeof(MENUITEMINFOW);
|
1999-04-01 12:24:21 +02:00
|
|
|
mii.fMask = MIIM_TYPE;
|
|
|
|
mii.cch = 0; /* WARNING: We MUST initialize it to 0*/
|
2004-10-19 05:56:40 +02:00
|
|
|
if (!GetMenuItemInfoW(hm, i, TRUE, &mii))
|
1999-07-25 14:26:05 +02:00
|
|
|
{
|
|
|
|
return(FALSE);
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mii.fType & MFT_SEPARATOR)
|
1999-07-25 14:26:05 +02:00
|
|
|
{
|
|
|
|
return(TRUE);
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
|
1999-07-25 14:26:05 +02:00
|
|
|
return(FALSE);
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
1999-07-25 14:26:05 +02:00
|
|
|
|
2005-06-20 12:30:15 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* Shell_MergeMenus [SHELL32.67]
|
|
|
|
*/
|
2010-07-20 10:11:48 +02:00
|
|
|
UINT WINAPI Shell_MergeMenus (HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags)
|
1999-04-01 12:24:21 +02:00
|
|
|
{ int nItem;
|
|
|
|
HMENU hmSubMenu;
|
|
|
|
BOOL bAlreadySeparated;
|
2004-10-19 05:56:40 +02:00
|
|
|
MENUITEMINFOW miiSrc;
|
|
|
|
WCHAR szName[256];
|
1999-04-01 12:24:21 +02:00
|
|
|
UINT uTemp, uIDMax = uIDAdjust;
|
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("hmenu1=%p hmenu2=%p 0x%04x 0x%04x 0x%04x 0x%04x\n",
|
1999-04-01 12:24:21 +02:00
|
|
|
hmDst, hmSrc, uInsert, uIDAdjust, uIDAdjustMax, uFlags);
|
|
|
|
|
|
|
|
if (!hmDst || !hmSrc)
|
2010-01-09 14:59:22 +01:00
|
|
|
return uIDMax;
|
1999-04-01 12:24:21 +02:00
|
|
|
|
|
|
|
nItem = GetMenuItemCount(hmDst);
|
2010-01-09 14:59:22 +01:00
|
|
|
if (nItem == -1)
|
|
|
|
return uIDMax;
|
1999-07-25 14:26:05 +02:00
|
|
|
|
|
|
|
if (uInsert >= (UINT)nItem) /* insert position inside menu? */
|
|
|
|
{
|
|
|
|
uInsert = (UINT)nItem; /* append on the end */
|
1999-04-01 12:24:21 +02:00
|
|
|
bAlreadySeparated = TRUE;
|
|
|
|
}
|
|
|
|
else
|
1999-07-25 14:26:05 +02:00
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
bAlreadySeparated = _SHIsMenuSeparator(hmDst, uInsert);
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
1999-07-25 14:26:05 +02:00
|
|
|
|
1999-04-01 12:24:21 +02:00
|
|
|
if ((uFlags & MM_ADDSEPARATOR) && !bAlreadySeparated)
|
1999-07-25 14:26:05 +02:00
|
|
|
{
|
|
|
|
/* Add a separator between the menus */
|
1999-04-01 12:24:21 +02:00
|
|
|
InsertMenuA(hmDst, uInsert, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
|
|
|
|
bAlreadySeparated = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Go through the menu items and clone them*/
|
|
|
|
for (nItem = GetMenuItemCount(hmSrc) - 1; nItem >= 0; nItem--)
|
1999-07-25 14:26:05 +02:00
|
|
|
{
|
2004-10-19 05:56:40 +02:00
|
|
|
miiSrc.cbSize = sizeof(MENUITEMINFOW);
|
1999-07-25 14:26:05 +02:00
|
|
|
miiSrc.fMask = MIIM_STATE | MIIM_ID | MIIM_SUBMENU | MIIM_CHECKMARKS | MIIM_TYPE | MIIM_DATA;
|
|
|
|
|
|
|
|
/* We need to reset this every time through the loop in case menus DON'T have IDs*/
|
1999-04-01 12:24:21 +02:00
|
|
|
miiSrc.fType = MFT_STRING;
|
|
|
|
miiSrc.dwTypeData = szName;
|
|
|
|
miiSrc.dwItemData = 0;
|
2018-03-19 08:11:27 +01:00
|
|
|
miiSrc.cch = ARRAY_SIZE(szName);
|
1999-04-01 12:24:21 +02:00
|
|
|
|
2004-10-19 05:56:40 +02:00
|
|
|
if (!GetMenuItemInfoW(hmSrc, nItem, TRUE, &miiSrc))
|
1999-07-25 14:26:05 +02:00
|
|
|
{
|
|
|
|
continue;
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
1999-07-25 14:26:05 +02:00
|
|
|
|
|
|
|
/* TRACE("found menu=0x%04x %s id=0x%04x mask=0x%08x smenu=0x%04x\n", hmSrc, debugstr_a(miiSrc.dwTypeData), miiSrc.wID, miiSrc.fMask, miiSrc.hSubMenu);
|
|
|
|
*/
|
1999-04-01 12:24:21 +02:00
|
|
|
if (miiSrc.fType & MFT_SEPARATOR)
|
1999-07-25 14:26:05 +02:00
|
|
|
{
|
|
|
|
/* This is a separator; don't put two of them in a row */
|
1999-04-01 12:24:21 +02:00
|
|
|
if (bAlreadySeparated)
|
1999-07-25 14:26:05 +02:00
|
|
|
continue;
|
|
|
|
|
1999-04-01 12:24:21 +02:00
|
|
|
bAlreadySeparated = TRUE;
|
|
|
|
}
|
|
|
|
else if (miiSrc.hSubMenu)
|
1999-07-25 14:26:05 +02:00
|
|
|
{
|
|
|
|
if (uFlags & MM_SUBMENUSHAVEIDS)
|
|
|
|
{
|
|
|
|
miiSrc.wID += uIDAdjust; /* add uIDAdjust to the ID */
|
|
|
|
|
2011-08-02 22:20:32 +02:00
|
|
|
if (miiSrc.wID > uIDAdjustMax) /* skip IDs higher than uIDAdjustMax */
|
1999-07-25 14:26:05 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (uIDMax <= miiSrc.wID) /* remember the highest ID */
|
|
|
|
uIDMax = miiSrc.wID + 1;
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
else
|
1999-07-25 14:26:05 +02:00
|
|
|
{
|
|
|
|
miiSrc.fMask &= ~MIIM_ID; /* Don't set IDs for submenus that didn't have them already */
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
hmSubMenu = miiSrc.hSubMenu;
|
1999-07-25 14:26:05 +02:00
|
|
|
|
1999-04-01 12:24:21 +02:00
|
|
|
miiSrc.hSubMenu = CreatePopupMenu();
|
1999-07-25 14:26:05 +02:00
|
|
|
|
|
|
|
if (!miiSrc.hSubMenu) return(uIDMax);
|
|
|
|
|
|
|
|
uTemp = Shell_MergeMenus(miiSrc.hSubMenu, hmSubMenu, 0, uIDAdjust, uIDAdjustMax, uFlags & MM_SUBMENUSHAVEIDS);
|
|
|
|
|
1999-04-01 12:24:21 +02:00
|
|
|
if (uIDMax <= uTemp)
|
1999-07-25 14:26:05 +02:00
|
|
|
uIDMax = uTemp;
|
|
|
|
|
1999-04-01 12:24:21 +02:00
|
|
|
bAlreadySeparated = FALSE;
|
|
|
|
}
|
1999-07-25 14:26:05 +02:00
|
|
|
else /* normal menu item */
|
|
|
|
{
|
|
|
|
miiSrc.wID += uIDAdjust; /* add uIDAdjust to the ID */
|
|
|
|
|
2011-08-02 22:20:32 +02:00
|
|
|
if (miiSrc.wID > uIDAdjustMax) /* skip IDs higher than uIDAdjustMax */
|
1999-07-25 14:26:05 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (uIDMax <= miiSrc.wID) /* remember the highest ID */
|
|
|
|
uIDMax = miiSrc.wID + 1;
|
|
|
|
|
1999-04-01 12:24:21 +02:00
|
|
|
bAlreadySeparated = FALSE;
|
|
|
|
}
|
1999-07-25 14:26:05 +02:00
|
|
|
|
|
|
|
/* TRACE("inserting menu=0x%04x %s id=0x%04x mask=0x%08x smenu=0x%04x\n", hmDst, debugstr_a(miiSrc.dwTypeData), miiSrc.wID, miiSrc.fMask, miiSrc.hSubMenu);
|
|
|
|
*/
|
2004-10-19 05:56:40 +02:00
|
|
|
if (!InsertMenuItemW(hmDst, uInsert, TRUE, &miiSrc))
|
1999-07-25 14:26:05 +02:00
|
|
|
{
|
|
|
|
return(uIDMax);
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ensure the correct number of separators at the beginning of the
|
|
|
|
inserted menu items*/
|
|
|
|
if (uInsert == 0)
|
1999-07-25 14:26:05 +02:00
|
|
|
{
|
|
|
|
if (bAlreadySeparated)
|
|
|
|
{
|
|
|
|
DeleteMenu(hmDst, uInsert, MF_BYPOSITION);
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
1999-07-25 14:26:05 +02:00
|
|
|
{
|
|
|
|
if (_SHIsMenuSeparator(hmDst, uInsert-1))
|
|
|
|
{
|
|
|
|
if (bAlreadySeparated)
|
|
|
|
{
|
|
|
|
DeleteMenu(hmDst, uInsert, MF_BYPOSITION);
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
1999-07-25 14:26:05 +02:00
|
|
|
{
|
|
|
|
if ((uFlags & MM_ADDSEPARATOR) && !bAlreadySeparated)
|
|
|
|
{
|
|
|
|
/* Add a separator between the menus*/
|
2004-10-19 05:56:40 +02:00
|
|
|
InsertMenuW(hmDst, uInsert, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
|
1999-04-01 12:24:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(uIDMax);
|
|
|
|
}
|
2011-08-03 23:42:17 +02:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
IContextMenu3 IContextMenu3_iface;
|
|
|
|
IContextMenu **menus;
|
|
|
|
UINT *offsets;
|
|
|
|
UINT menu_count;
|
|
|
|
ULONG refCount;
|
|
|
|
}CompositeCMenu;
|
|
|
|
|
|
|
|
static const IContextMenu3Vtbl CompositeCMenuVtbl;
|
|
|
|
|
|
|
|
static CompositeCMenu* impl_from_IContextMenu3(IContextMenu3* iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, CompositeCMenu, IContextMenu3_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT CompositeCMenu_Constructor(IContextMenu **menus,UINT menu_count, REFIID riid, void **ppv)
|
|
|
|
{
|
2018-02-22 08:43:28 +01:00
|
|
|
CompositeCMenu *ret;
|
2011-08-03 23:42:17 +02:00
|
|
|
UINT i;
|
2018-02-22 08:43:28 +01:00
|
|
|
|
2011-08-03 23:42:17 +02:00
|
|
|
TRACE("(%p,%u,%s,%p)\n",menus,menu_count,shdebugstr_guid(riid),ppv);
|
2018-02-22 08:43:28 +01:00
|
|
|
|
|
|
|
ret = heap_alloc(sizeof(*ret));
|
2011-08-03 23:42:17 +02:00
|
|
|
if(!ret)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
ret->IContextMenu3_iface.lpVtbl = &CompositeCMenuVtbl;
|
|
|
|
ret->menu_count = menu_count;
|
2018-02-22 08:43:28 +01:00
|
|
|
ret->menus = heap_alloc(menu_count*sizeof(IContextMenu*));
|
2011-08-03 23:42:17 +02:00
|
|
|
if(!ret->menus)
|
|
|
|
{
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(ret);
|
2011-08-03 23:42:17 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2018-02-22 08:43:28 +01:00
|
|
|
ret->offsets = heap_alloc_zero(menu_count*sizeof(UINT));
|
2011-08-03 23:42:17 +02:00
|
|
|
if(!ret->offsets)
|
|
|
|
{
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(ret->menus);
|
|
|
|
heap_free(ret);
|
2011-08-03 23:42:17 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
ret->refCount=0;
|
|
|
|
memcpy(ret->menus,menus,menu_count*sizeof(IContextMenu*));
|
|
|
|
for(i=0;i<menu_count;i++)
|
|
|
|
IContextMenu_AddRef(menus[i]);
|
|
|
|
return IContextMenu3_QueryInterface(&(ret->IContextMenu3_iface),riid,ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CompositeCMenu_Destroy(CompositeCMenu *This)
|
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
for(i=0;i<This->menu_count;i++)
|
|
|
|
IContextMenu_Release(This->menus[i]);
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(This->menus);
|
|
|
|
heap_free(This->offsets);
|
|
|
|
heap_free(This);
|
2011-08-03 23:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI CompositeCMenu_QueryInterface(IContextMenu3 *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%s,%p)\n",iface,shdebugstr_guid(riid),ppv);
|
|
|
|
if(!ppv)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if(IsEqualIID(riid,&IID_IUnknown) || IsEqualIID(riid,&IID_IContextMenu) ||
|
|
|
|
IsEqualIID(riid,&IID_IContextMenu2) || IsEqualIID(riid,&IID_IContextMenu3))
|
|
|
|
*ppv=iface;
|
|
|
|
else
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
IContextMenu3_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI CompositeCMenu_AddRef(IContextMenu3 *iface)
|
|
|
|
{
|
|
|
|
CompositeCMenu *This = impl_from_IContextMenu3(iface);
|
|
|
|
TRACE("(%p)->()\n",iface);
|
|
|
|
return ++This->refCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI CompositeCMenu_Release(IContextMenu3 *iface)
|
|
|
|
{
|
|
|
|
CompositeCMenu *This = impl_from_IContextMenu3(iface);
|
|
|
|
TRACE("(%p)->()\n",iface);
|
|
|
|
if(--This->refCount)
|
|
|
|
return This->refCount;
|
|
|
|
CompositeCMenu_Destroy(This);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-08-05 09:56:34 +02:00
|
|
|
static UINT CompositeCMenu_GetIndexForCommandId(CompositeCMenu *This,UINT id)
|
2011-08-03 23:42:17 +02:00
|
|
|
{
|
|
|
|
UINT low=0;
|
|
|
|
UINT high=This->menu_count;
|
|
|
|
while(high-low!=1)
|
|
|
|
{
|
|
|
|
UINT i=(high+low)/2;
|
|
|
|
if(This->offsets[i]<=id)
|
|
|
|
low=i;
|
|
|
|
else
|
|
|
|
high=i;
|
|
|
|
}
|
|
|
|
return low;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI CompositeCMenu_GetCommandString(IContextMenu3* iface, UINT_PTR idCmd, UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax)
|
|
|
|
{
|
|
|
|
CompositeCMenu *This = impl_from_IContextMenu3(iface);
|
|
|
|
UINT index = CompositeCMenu_GetIndexForCommandId(This,idCmd);
|
|
|
|
TRACE("(%p)->(%lx,%x,%p,%s,%u)\n",iface,idCmd,uFlags,pwReserved,pszName,cchMax);
|
|
|
|
return IContextMenu_GetCommandString(This->menus[index],idCmd,uFlags,pwReserved,pszName,cchMax);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI CompositeCMenu_InvokeCommand(IContextMenu3* iface,LPCMINVOKECOMMANDINFO pici)
|
|
|
|
{
|
|
|
|
CompositeCMenu *This = impl_from_IContextMenu3(iface);
|
2017-06-09 01:36:16 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", iface, pici);
|
|
|
|
|
|
|
|
if (IS_INTRESOURCE(pici->lpVerb))
|
|
|
|
{
|
|
|
|
UINT id = (UINT_PTR)pici->lpVerb;
|
|
|
|
UINT index = CompositeCMenu_GetIndexForCommandId(This, id);
|
|
|
|
return IContextMenu_InvokeCommand(This->menus[index], pici);
|
|
|
|
}
|
|
|
|
else
|
2011-08-03 23:42:17 +02:00
|
|
|
{
|
|
|
|
/*call each handler until one of them succeeds*/
|
2017-06-09 01:36:16 +02:00
|
|
|
UINT i;
|
|
|
|
|
|
|
|
for (i = 0; i < This->menu_count; i++)
|
2011-08-03 23:42:17 +02:00
|
|
|
{
|
|
|
|
HRESULT hres;
|
2017-06-09 01:36:16 +02:00
|
|
|
if (SUCCEEDED(hres = IContextMenu_InvokeCommand(This->menus[i], pici)))
|
2011-08-03 23:42:17 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI CompositeCMenu_QueryContextMenu(IContextMenu3 *iface, HMENU hmenu,UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
|
|
|
|
{
|
|
|
|
CompositeCMenu *This = impl_from_IContextMenu3(iface);
|
|
|
|
UINT i=0;
|
|
|
|
UINT id_offset=idCmdFirst;
|
|
|
|
TRACE("(%p)->(%p,%u,%u,%u,%x)\n",iface,hmenu,indexMenu,idCmdFirst,idCmdLast,uFlags);
|
|
|
|
for(;i<This->menu_count;i++)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
This->offsets[i]=id_offset;
|
|
|
|
hres = IContextMenu_QueryContextMenu(This->menus[i],hmenu,indexMenu,id_offset,idCmdLast,uFlags);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
id_offset+=hres;
|
|
|
|
}
|
|
|
|
return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, id_offset-idCmdFirst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI CompositeCMenu_HandleMenuMsg(IContextMenu3 *iface, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
CompositeCMenu *This = impl_from_IContextMenu3(iface);
|
|
|
|
HMENU menu;
|
|
|
|
UINT id;
|
|
|
|
UINT index;
|
|
|
|
IContextMenu2 *handler;
|
|
|
|
HRESULT hres;
|
|
|
|
TRACE("(%p)->(%x,%lx,%lx)\n",iface,uMsg,wParam,lParam);
|
|
|
|
switch(uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITMENUPOPUP:
|
|
|
|
menu = (HMENU)wParam;
|
|
|
|
id = GetMenuItemID(menu,LOWORD(lParam));
|
|
|
|
break;
|
|
|
|
case WM_DRAWITEM:
|
|
|
|
id = ((DRAWITEMSTRUCT*)lParam)->itemID;
|
|
|
|
break;
|
|
|
|
case WM_MEASUREITEM:
|
|
|
|
id = ((MEASUREITEMSTRUCT*)lParam)->itemID;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN("Unimplemented uMsg: 0x%x\n",uMsg);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
index = CompositeCMenu_GetIndexForCommandId(This,id);
|
|
|
|
hres = IContextMenu_QueryInterface(This->menus[index],&IID_IContextMenu2,
|
|
|
|
(void**)&handler);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
return IContextMenu2_HandleMenuMsg(handler,uMsg,wParam,lParam);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI CompositeCMenu_HandleMenuMsg2(IContextMenu3 *iface, UINT uMsg, WPARAM wParam, LPARAM lParam,LRESULT *plResult)
|
|
|
|
{
|
|
|
|
CompositeCMenu *This = impl_from_IContextMenu3(iface);
|
|
|
|
HMENU menu;
|
|
|
|
UINT id;
|
|
|
|
UINT index;
|
|
|
|
IContextMenu3 *handler;
|
|
|
|
HRESULT hres;
|
|
|
|
LRESULT lres;
|
|
|
|
TRACE("(%p)->(%x,%lx,%lx,%p)\n",iface,uMsg,wParam,lParam,plResult);
|
|
|
|
if(!plResult)
|
|
|
|
plResult=&lres;
|
|
|
|
switch(uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITMENUPOPUP:
|
|
|
|
menu = (HMENU)wParam;
|
|
|
|
id = GetMenuItemID(menu,LOWORD(lParam));
|
|
|
|
break;
|
|
|
|
case WM_DRAWITEM:
|
|
|
|
id = ((DRAWITEMSTRUCT*)lParam)->itemID;
|
|
|
|
break;
|
|
|
|
case WM_MEASUREITEM:
|
|
|
|
id = ((MEASUREITEMSTRUCT*)lParam)->itemID;
|
|
|
|
break;
|
|
|
|
case WM_MENUCHAR:
|
|
|
|
{
|
|
|
|
UINT i=0;
|
|
|
|
for(;i<This->menu_count;i++)
|
|
|
|
{
|
|
|
|
hres = IContextMenu_QueryInterface(This->menus[i],&IID_IContextMenu3,(void**)&handler);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
hres = IContextMenu3_HandleMenuMsg2(handler,uMsg,wParam,lParam,plResult);
|
|
|
|
if(SUCCEEDED(hres) && HIWORD(*plResult))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
WARN("Unimplemented uMsg: 0x%x\n",uMsg);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
index = CompositeCMenu_GetIndexForCommandId(This,id);
|
|
|
|
hres = IContextMenu_QueryInterface(This->menus[index],&IID_IContextMenu3,(void**)&handler);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
return IContextMenu3_HandleMenuMsg2(handler,uMsg,wParam,lParam,plResult);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IContextMenu3Vtbl CompositeCMenuVtbl=
|
|
|
|
{
|
|
|
|
CompositeCMenu_QueryInterface,
|
|
|
|
CompositeCMenu_AddRef,
|
|
|
|
CompositeCMenu_Release,
|
|
|
|
CompositeCMenu_QueryContextMenu,
|
|
|
|
CompositeCMenu_InvokeCommand,
|
|
|
|
CompositeCMenu_GetCommandString,
|
|
|
|
CompositeCMenu_HandleMenuMsg,
|
|
|
|
CompositeCMenu_HandleMenuMsg2
|
|
|
|
};
|
|
|
|
|
2011-08-05 09:56:41 +02:00
|
|
|
static HRESULT SHELL_CreateContextMenu(HWND hwnd, IContextMenu* system_menu,
|
2011-08-03 23:42:17 +02:00
|
|
|
IShellFolder *folder, LPCITEMIDLIST folder_pidl,
|
|
|
|
LPCITEMIDLIST *apidl, UINT cidl, const HKEY *aKeys,
|
|
|
|
UINT cKeys,REFIID riid, void** ppv)
|
|
|
|
{
|
|
|
|
HRESULT ret;
|
|
|
|
TRACE("(%p,%p,%p,%p,%p,%u,%p,%u,%s,%p)\n",hwnd,system_menu,folder,folder_pidl,apidl,cidl,aKeys,cKeys,shdebugstr_guid(riid),ppv);
|
|
|
|
ret = CompositeCMenu_Constructor(&system_menu,1,riid,ppv);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI CDefFolderMenu_Create2(LPCITEMIDLIST pidlFolder, HWND hwnd, UINT cidl,
|
|
|
|
LPCITEMIDLIST *apidl, IShellFolder *psf,
|
|
|
|
LPFNDFMCALLBACK lpfn, UINT nKeys, const HKEY *ahkeys,
|
|
|
|
IContextMenu **ppcm)
|
|
|
|
{
|
|
|
|
IContextMenu *system_menu;
|
|
|
|
HRESULT hres;
|
|
|
|
LPITEMIDLIST folder_pidl;
|
|
|
|
TRACE("(%p,%p,%u,%p,%p,%u,%p,%p)\n",pidlFolder,hwnd,cidl,apidl,psf,nKeys,ahkeys,ppcm);
|
|
|
|
if(!pidlFolder)
|
|
|
|
{
|
|
|
|
IPersistFolder2 *persist;
|
|
|
|
IShellFolder_QueryInterface(psf,&IID_IPersistFolder2,(void**)&persist);
|
|
|
|
IPersistFolder2_GetCurFolder(persist,&folder_pidl);
|
|
|
|
IPersistFolder2_Release(persist);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
folder_pidl=ILClone(pidlFolder);
|
2012-01-11 03:02:03 +01:00
|
|
|
|
|
|
|
ItemMenu_Constructor(psf, folder_pidl, (const LPCITEMIDLIST*)apidl, cidl, &IID_IContextMenu, (void**)&system_menu);
|
2011-08-03 23:42:17 +02:00
|
|
|
hres= SHELL_CreateContextMenu(hwnd,system_menu,psf,folder_pidl,apidl,cidl,ahkeys,nKeys,&IID_IContextMenu,(void**)ppcm);
|
|
|
|
IContextMenu_Release(system_menu);
|
|
|
|
ILFree(folder_pidl);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI SHCreateDefaultContextMenu(const DEFCONTEXTMENU *pdcm, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
IShellFolder *folder=pdcm->psf;
|
|
|
|
LPITEMIDLIST folder_pidl;
|
|
|
|
HRESULT ret;
|
|
|
|
IContextMenu *system_menu;
|
|
|
|
TRACE("(%p,%s,%p)\n",pdcm,shdebugstr_guid(riid),ppv);
|
|
|
|
if(!pdcm->pidlFolder)
|
|
|
|
{
|
|
|
|
IPersistFolder2 *persist;
|
|
|
|
IShellFolder_QueryInterface(folder,&IID_IPersistFolder2,(void**)&persist);
|
|
|
|
IPersistFolder2_GetCurFolder(persist,&folder_pidl);
|
|
|
|
IPersistFolder2_Release(persist);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
folder_pidl=ILClone(pdcm->pidlFolder);
|
|
|
|
if(pdcm->cKeys==0)
|
|
|
|
FIXME("Loading shell extensions using IQueryAssociations not yet supported\n");
|
2012-01-11 03:02:03 +01:00
|
|
|
|
|
|
|
ItemMenu_Constructor(folder, folder_pidl, (const LPCITEMIDLIST*)pdcm->apidl, pdcm->cidl, &IID_IContextMenu, (void**)&system_menu);
|
2011-08-03 23:42:17 +02:00
|
|
|
ret = SHELL_CreateContextMenu(pdcm->hwnd,system_menu,folder,folder_pidl,(LPCITEMIDLIST*)pdcm->apidl,pdcm->cidl,pdcm->aKeys,pdcm->cKeys,riid,ppv);
|
|
|
|
IContextMenu_Release(system_menu);
|
|
|
|
ILFree(folder_pidl);
|
|
|
|
return ret;
|
|
|
|
}
|