- Fix loading of MENUEX resources

svn path=/trunk/; revision=55043
This commit is contained in:
Rafal Harabien 2012-01-21 13:55:09 +00:00
parent 74a51ae888
commit c52fdad546

View file

@ -2068,14 +2068,15 @@ static LPCSTR MENU_ParseResource( LPCSTR res, HMENU hMenu, BOOL unicode )
* Parse an extended menu resource and add items to the menu. * Parse an extended menu resource and add items to the menu.
* Return a pointer to the end of the resource. * Return a pointer to the end of the resource.
*/ */
static LPCSTR MENUEX_ParseResource( LPCSTR res, HMENU hMenu) static LPCSTR MENUEX_ParseResource(LPCSTR res, HMENU hMenu)
{ {
WORD resinfo; WORD resinfo;
do { MENUITEMINFOW mii;
MENUITEMINFOW mii;
do
{
mii.cbSize = sizeof(mii); mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STATE | MIIM_ID | MIIM_FTYPE; mii.fMask = MIIM_STATE | MIIM_ID | MIIM_TYPE;
mii.fType = GET_DWORD(res); mii.fType = GET_DWORD(res);
res += sizeof(DWORD); res += sizeof(DWORD);
mii.fState = GET_DWORD(res); mii.fState = GET_DWORD(res);
@ -2086,7 +2087,8 @@ static LPCSTR MENUEX_ParseResource( LPCSTR res, HMENU hMenu)
res += sizeof(WORD); res += sizeof(WORD);
/* Align the text on a word boundary. */ /* Align the text on a word boundary. */
res += (~((UINT_PTR)res - 1)) & 1; res += (~((UINT_PTR)res - 1)) & 1;
mii.dwTypeData = (LPWSTR) res; mii.dwTypeData = (LPWSTR)res;
mii.cch = strlenW(mii.dwTypeData);
res += (1 + strlenW(mii.dwTypeData)) * sizeof(WCHAR); res += (1 + strlenW(mii.dwTypeData)) * sizeof(WCHAR);
/* Align the following fields on a dword boundary. */ /* Align the following fields on a dword boundary. */
res += (~((UINT_PTR)res - 1)) & 3; res += (~((UINT_PTR)res - 1)) & 3;
@ -2094,25 +2096,32 @@ static LPCSTR MENUEX_ParseResource( LPCSTR res, HMENU hMenu)
TRACE("Menu item: [%08x,%08x,%04x,%04x,%S]\n", TRACE("Menu item: [%08x,%08x,%04x,%04x,%S]\n",
mii.fType, mii.fState, mii.wID, resinfo, mii.dwTypeData); mii.fType, mii.fState, mii.wID, resinfo, mii.dwTypeData);
if (resinfo & 1) { /* Pop-up? */ if (resinfo & 1) /* Pop-up? */
/* DWORD helpid = GET_DWORD(res); FIXME: use this. */ {
/* DWORD helpid = GET_DWORD(res); FIXME: use this. */
res += sizeof(DWORD); res += sizeof(DWORD);
mii.hSubMenu = CreatePopupMenu(); mii.hSubMenu = CreatePopupMenu();
if (!mii.hSubMenu) if (!mii.hSubMenu)
{
ERR("CreatePopupMenu failed\n");
return NULL; return NULL;
if (!(res = MENUEX_ParseResource(res, mii.hSubMenu))) { }
if (!(res = MENUEX_ParseResource(res, mii.hSubMenu)))
{
ERR("MENUEX_ParseResource failed\n");
DestroyMenu(mii.hSubMenu); DestroyMenu(mii.hSubMenu);
return NULL; return NULL;
} }
mii.fMask |= MIIM_SUBMENU; mii.fMask |= MIIM_SUBMENU;
mii.fType |= MF_POPUP; mii.fType |= MF_POPUP;
mii.wID = (UINT) mii.hSubMenu; mii.wID = (UINT)mii.hSubMenu;
} }
else if(!*mii.dwTypeData && !(mii.fType & MF_SEPARATOR)) else if (!mii.dwTypeData[0])
{
mii.fType |= MF_SEPARATOR; mii.fType |= MF_SEPARATOR;
}
InsertMenuItemW(hMenu, -1, MF_BYPOSITION, &mii); if (!InsertMenuItemW(hMenu, -1, MF_BYPOSITION, &mii))
ERR("InsertMenuItemW failed\n");
} while (!(resinfo & MF_END)); } while (!(resinfo & MF_END));
return res; return res;
} }
@ -4807,7 +4816,7 @@ LoadMenuIndirectW(CONST MENUTEMPLATE *lpMenuTemplate)
} }
return hMenu; return hMenu;
default: default:
DbgPrint("LoadMenuIndirectW(): version %d not supported.\n", version); ERR("Menu template version %d not supported.\n", version);
return 0; return 0;
} }
} }