From 6a45c0b4b48aedf8ab5e865f098589b034fe9c02 Mon Sep 17 00:00:00 2001 From: Charles Duffy Date: Tue, 26 Feb 2002 00:34:19 +0000 Subject: [PATCH] Stop TOOLBAR_MeasureString from dying on empty strings. --- dlls/comctl32/toolbar.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index 46ee8f85e10..bae03977dfc 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -819,22 +819,24 @@ TOOLBAR_MeasureString(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, { LPWSTR lpText = TOOLBAR_GetText(infoPtr, btnPtr); - /* first get size of all the text */ - GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize); + if(lpText != NULL) { + /* first get size of all the text */ + GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize); - /* feed above size into the rectangle for DrawText */ - myrect.left = myrect.top = 0; - myrect.right = lpSize->cx; - myrect.bottom = lpSize->cy; + /* feed above size into the rectangle for DrawText */ + myrect.left = myrect.top = 0; + myrect.right = lpSize->cx; + myrect.bottom = lpSize->cy; - /* Use DrawText to get true size as drawn (less pesky "&") */ - DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE | - DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ? + /* Use DrawText to get true size as drawn (less pesky "&") */ + DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE | + DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ? DT_NOPREFIX : 0)); - /* feed back to caller */ - lpSize->cx = myrect.right; - lpSize->cy = myrect.bottom; + /* feed back to caller */ + lpSize->cx = myrect.right; + lpSize->cy = myrect.bottom; + } } TRACE("string size %ld x %ld!\n", lpSize->cx, lpSize->cy);