comctl32/button: Use WM_GETTEXTLENGTH to see if the button has any text.
There's no reason to allocate and then parse the entire string just to see if its length is zero. Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
715065feb3
commit
8ee1e3453e
|
@ -1276,20 +1276,16 @@ static BOOL GB_GetIdealSize(BUTTON_INFO *infoPtr, SIZE *size)
|
|||
static BOOL CB_GetIdealSize(BUTTON_INFO *infoPtr, SIZE *size)
|
||||
{
|
||||
LONG style = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
|
||||
WCHAR *text = get_button_text(infoPtr);
|
||||
HDC hdc;
|
||||
HFONT hfont;
|
||||
SIZE labelSize;
|
||||
INT textOffset;
|
||||
INT textLength = 0;
|
||||
double scaleX;
|
||||
double scaleY;
|
||||
LONG checkboxWidth, checkboxHeight;
|
||||
LONG maxWidth = 0;
|
||||
|
||||
if (text) textLength = lstrlenW(text);
|
||||
heap_free(text);
|
||||
if (textLength == 0)
|
||||
if (SendMessageW(infoPtr->hwnd, WM_GETTEXTLENGTH, 0, 0) == 0)
|
||||
{
|
||||
BUTTON_GetClientRectSize(infoPtr, size);
|
||||
return TRUE;
|
||||
|
@ -1325,26 +1321,18 @@ static BOOL CB_GetIdealSize(BUTTON_INFO *infoPtr, SIZE *size)
|
|||
|
||||
static BOOL PB_GetIdealSize(BUTTON_INFO *infoPtr, SIZE *size)
|
||||
{
|
||||
WCHAR *text = get_button_text(infoPtr);
|
||||
SIZE labelSize;
|
||||
INT textLength = 0;
|
||||
|
||||
if (text) textLength = lstrlenW(text);
|
||||
|
||||
if (textLength == 0)
|
||||
{
|
||||
if (SendMessageW(infoPtr->hwnd, WM_GETTEXTLENGTH, 0, 0) == 0)
|
||||
BUTTON_GetClientRectSize(infoPtr, size);
|
||||
heap_free(text);
|
||||
return TRUE;
|
||||
else
|
||||
{
|
||||
/* Ideal size include text size even if image only flags(BS_ICON, BS_BITMAP) are specified */
|
||||
BUTTON_GetLabelIdealSize(infoPtr, size->cx, &labelSize);
|
||||
|
||||
size->cx = labelSize.cx;
|
||||
size->cy = labelSize.cy;
|
||||
}
|
||||
heap_free(text);
|
||||
|
||||
/* Ideal size include text size even if image only flags(BS_ICON, BS_BITMAP) are specified */
|
||||
BUTTON_GetLabelIdealSize(infoPtr, size->cx, &labelSize);
|
||||
|
||||
size->cx = labelSize.cx;
|
||||
size->cy = labelSize.cy;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue