From 2d6eabacc32ce25e6bf7c5f032a6e638291d3b88 Mon Sep 17 00:00:00 2001 From: Huw D M Davies Date: Fri, 24 Mar 2000 19:48:53 +0000 Subject: [PATCH] Set the correct value for the cch element of MENUITEMINFO in GetMenuItemInfo. --- controls/menu.c | 52 +++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/controls/menu.c b/controls/menu.c index fa915d82c77..6eeb6088e4f 100644 --- a/controls/menu.c +++ b/controls/menu.c @@ -4293,34 +4293,40 @@ static BOOL GetMenuItemInfo_common ( HMENU hmenu, UINT item, BOOL bypos, if (lpmii->fMask & MIIM_TYPE) { 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 { - lstrcpynA(lpmii->dwTypeData, menu->text, lpmii->cch); - lpmii->cch = lstrlenA(menu->text); - } - } - break; - case MF_OWNERDRAW: - case MF_BITMAP: - lpmii->dwTypeData = menu->text; - /* fall through */ - default: - lpmii->cch = 0; + case MF_STRING: + 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); + /* 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: + case MF_BITMAP: + lpmii->dwTypeData = menu->text; + /* fall through */ + default: + lpmii->cch = 0; } } if (lpmii->fMask & MIIM_STRING) { - if (unicode) { - lstrcpynAtoW((LPWSTR) lpmii->dwTypeData, menu->text, lpmii->cch); - lpmii->cch = lstrlenW((LPWSTR)menu->text); - } else { - lstrcpynA(lpmii->dwTypeData, menu->text, lpmii->cch); - lpmii->cch = 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 (lpmii->fMask & MIIM_FTYPE)