Commit 5d657a10 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/listview: Use proper A/W call to measure item text string.

parent b65423c5
...@@ -5873,20 +5873,20 @@ static HWND CreateEditLabelT(LISTVIEW_INFO *infoPtr, LPCWSTR text, BOOL isW) ...@@ -5873,20 +5873,20 @@ static HWND CreateEditLabelT(LISTVIEW_INFO *infoPtr, LPCWSTR text, BOOL isW)
static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *infoPtr, INT nItem, BOOL isW) static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *infoPtr, INT nItem, BOOL isW)
{ {
WCHAR szDispText[DISP_TEXT_SIZE] = { 0 }; WCHAR szDispText[DISP_TEXT_SIZE] = { 0 };
HWND hwndSelf = infoPtr->hwndSelf;
NMLVDISPINFOW dispInfo; NMLVDISPINFOW dispInfo;
HFONT hOldFont = NULL;
TEXTMETRICW tm;
RECT rect; RECT rect;
SIZE sz; SIZE sz;
HWND hwndSelf = infoPtr->hwndSelf;
HDC hdc; HDC hdc;
HFONT hOldFont = NULL;
TEXTMETRICW textMetric;
TRACE("(nItem=%d, isW=%d)\n", nItem, isW); TRACE("(nItem=%d, isW=%d)\n", nItem, isW);
if (~infoPtr->dwStyle & LVS_EDITLABELS) return 0; if (~infoPtr->dwStyle & LVS_EDITLABELS) return 0;
/* Is the EditBox still there, if so remove it */ /* remove existing edit box */
if(infoPtr->hwndEdit != 0) if (infoPtr->hwndEdit)
{ {
SetFocus(infoPtr->hwndSelf); SetFocus(infoPtr->hwndSelf);
infoPtr->hwndEdit = 0; infoPtr->hwndEdit = 0;
...@@ -5924,27 +5924,38 @@ static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *infoPtr, INT nItem, BOOL isW) ...@@ -5924,27 +5924,38 @@ static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *infoPtr, INT nItem, BOOL isW)
return 0; return 0;
} }
/* Now position and display edit box */ /* position and display edit box */
hdc = GetDC(infoPtr->hwndSelf); hdc = GetDC(infoPtr->hwndSelf);
/* Select the font to get appropriate metric dimensions */ /* select the font to get appropriate metric dimensions */
if(infoPtr->hFont != 0) if (infoPtr->hFont)
hOldFont = SelectObject(hdc, infoPtr->hFont); hOldFont = SelectObject(hdc, infoPtr->hFont);
/* Get String Length in pixels */ /* get string length in pixels */
GetTextExtentPoint32W(hdc, dispInfo.item.pszText, lstrlenW(dispInfo.item.pszText), &sz); TRACE("text=%s\n", debugtext_t(dispInfo.item.pszText, isW));
/* Add Extra spacing for the next character */ if (isW)
GetTextMetricsW(hdc, &textMetric); GetTextExtentPoint32W(hdc, dispInfo.item.pszText, lstrlenW(dispInfo.item.pszText), &sz);
sz.cx += (textMetric.tmMaxCharWidth * 2); else
{
const CHAR *textA = (CHAR*)dispInfo.item.pszText;
GetTextExtentPoint32A(hdc, textA, lstrlenA(textA), &sz);
}
/* add extra spacing for the next character */
GetTextMetricsW(hdc, &tm);
sz.cx += tm.tmMaxCharWidth * 2;
if(infoPtr->hFont != 0) if (infoPtr->hFont)
SelectObject(hdc, hOldFont); SelectObject(hdc, hOldFont);
ReleaseDC(infoPtr->hwndSelf, hdc); ReleaseDC(infoPtr->hwndSelf, hdc);
MoveWindow(infoPtr->hwndEdit, rect.left - 2, rect.top - 1, sz.cx, sz.cy = rect.bottom - rect.top + 2;
rect.bottom - rect.top + 2, FALSE); rect.left -= 2;
rect.top -= 1;
TRACE("moving edit=(%d,%d)-(%d,%d)\n", rect.left, rect.top, sz.cx, sz.cy);
MoveWindow(infoPtr->hwndEdit, rect.left, rect.top, sz.cx, sz.cy, FALSE);
ShowWindow(infoPtr->hwndEdit, SW_NORMAL); ShowWindow(infoPtr->hwndEdit, SW_NORMAL);
SetFocus(infoPtr->hwndEdit); SetFocus(infoPtr->hwndEdit);
SendMessageW(infoPtr->hwndEdit, EM_SETSEL, 0, -1); SendMessageW(infoPtr->hwndEdit, EM_SETSEL, 0, -1);
...@@ -6074,7 +6085,7 @@ static INT LISTVIEW_FindItemW(const LISTVIEW_INFO *infoPtr, INT nStart, ...@@ -6074,7 +6085,7 @@ static INT LISTVIEW_FindItemW(const LISTVIEW_INFO *infoPtr, INT nStart,
} }
if (!lpFindInfo || nItem < 0) return -1; if (!lpFindInfo || nItem < 0) return -1;
lvItem.mask = 0; lvItem.mask = 0;
if (lpFindInfo->flags & (LVFI_STRING | LVFI_PARTIAL) || if (lpFindInfo->flags & (LVFI_STRING | LVFI_PARTIAL) ||
lpFindInfo->flags & LVFI_SUBSTRING) lpFindInfo->flags & LVFI_SUBSTRING)
...@@ -6213,24 +6224,6 @@ static INT LISTVIEW_FindItemA(const LISTVIEW_INFO *infoPtr, INT nStart, ...@@ -6213,24 +6224,6 @@ static INT LISTVIEW_FindItemA(const LISTVIEW_INFO *infoPtr, INT nStart,
/*** /***
* DESCRIPTION: * DESCRIPTION:
* Retrieves the background image of the listview control.
*
* PARAMETER(S):
* [I] infoPtr : valid pointer to the listview structure
* [O] lpBkImage : background image attributes
*
* RETURN:
* SUCCESS : TRUE
* FAILURE : FALSE
*/
/* static BOOL LISTVIEW_GetBkImage(const LISTVIEW_INFO *infoPtr, LPLVBKIMAGE lpBkImage) */
/* { */
/* FIXME (listview, "empty stub!\n"); */
/* return FALSE; */
/* } */
/***
* DESCRIPTION:
* Retrieves column attributes. * Retrieves column attributes.
* *
* PARAMETER(S): * PARAMETER(S):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment