Set the correct value for the cch element of MENUITEMINFO in

GetMenuItemInfo.
This commit is contained in:
Huw D M Davies 2000-03-24 19:48:53 +00:00 committed by Alexandre Julliard
parent 70e16ad0e1
commit 2d6eabacc3
1 changed files with 29 additions and 23 deletions

View File

@ -4293,34 +4293,40 @@ static BOOL GetMenuItemInfo_common ( HMENU hmenu, UINT item, BOOL bypos,
if (lpmii->fMask & MIIM_TYPE) { if (lpmii->fMask & MIIM_TYPE) {
lpmii->fType = menu->fType; lpmii->fType = menu->fType;
switch (MENU_ITEM_TYPE(menu->fType)) { switch (MENU_ITEM_TYPE(menu->fType)) {
case MF_STRING: case MF_STRING:
if (menu->text && lpmii->dwTypeData && lpmii->cch) { if (menu->text) {
if (unicode) { int len = lstrlenA(menu->text);
lstrcpynAtoW((LPWSTR) lpmii->dwTypeData, menu->text, lpmii->cch); if(lpmii->dwTypeData && lpmii->cch) {
lpmii->cch = lstrlenW((LPWSTR)menu->text); if (unicode)
} else { lstrcpynAtoW((LPWSTR) lpmii->dwTypeData, menu->text,
lstrcpynA(lpmii->dwTypeData, menu->text, lpmii->cch); lpmii->cch);
lpmii->cch = lstrlenA(menu->text); else
} lstrcpynA(lpmii->dwTypeData, menu->text, lpmii->cch);
} /* if we've copied a substring we return its length */
break; if(lpmii->cch <= len)
case MF_OWNERDRAW: lpmii->cch--;
case MF_BITMAP: } else /* return length of string */
lpmii->dwTypeData = menu->text; lpmii->cch = len;
/* fall through */ }
default: break;
lpmii->cch = 0; case MF_OWNERDRAW:
case MF_BITMAP:
lpmii->dwTypeData = menu->text;
/* fall through */
default:
lpmii->cch = 0;
} }
} }
if (lpmii->fMask & MIIM_STRING) { if (lpmii->fMask & MIIM_STRING) {
if (unicode) { if(lpmii->dwTypeData && lpmii->cch) {
lstrcpynAtoW((LPWSTR) lpmii->dwTypeData, menu->text, lpmii->cch); if (unicode)
lpmii->cch = lstrlenW((LPWSTR)menu->text); lstrcpynAtoW((LPWSTR) lpmii->dwTypeData, menu->text,
} else { lpmii->cch);
lstrcpynA(lpmii->dwTypeData, menu->text, lpmii->cch); else
lpmii->cch = lstrlenA(menu->text); lstrcpynA(lpmii->dwTypeData, menu->text, lpmii->cch);
} }
lpmii->cch = lstrlenA(menu->text);
} }
if (lpmii->fMask & MIIM_FTYPE) if (lpmii->fMask & MIIM_FTYPE)