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

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