diff --git a/dll/win32/comctl32/listview.c b/dll/win32/comctl32/listview.c index 4119c27a90..7ebdc7df51 100644 --- a/dll/win32/comctl32/listview.c +++ b/dll/win32/comctl32/listview.c @@ -6086,6 +6086,52 @@ cleanup: return res; } +#ifdef __REACTOS__ +static void LISTVIEW_ResizeEdit(LISTVIEW_INFO *infoPtr) +{ + WCHAR disptextW[DISP_TEXT_SIZE]; + RECT rcText, rect; + SIZE labelSize; + HDC hDC; + HGDIOBJ hOldFont; + UINT uFormat; + + GetWindowRect(infoPtr->hwndEdit, &rect); + + GetWindowTextW(infoPtr->hwndEdit, disptextW, DISP_TEXT_SIZE); + + SetRectEmpty(&rcText); + rcText.right = infoPtr->nItemWidth - TRAILING_LABEL_PADDING; + rcText.bottom = infoPtr->nItemHeight; + if (infoPtr->uView == LV_VIEW_ICON) + rcText.bottom -= ICON_TOP_PADDING + infoPtr->iconSize.cy + ICON_BOTTOM_PADDING; + + uFormat = ((infoPtr->uView == LV_VIEW_ICON) ? LV_FL_DT_FLAGS : LV_SL_DT_FLAGS); + + hDC = GetDC(infoPtr->hwndEdit); + { + if (infoPtr->hFont) + hOldFont = SelectObject(hDC, infoPtr->hFont); + + DrawTextW(hDC, disptextW, -1, &rcText, uFormat | DT_CALCRECT); + + if (infoPtr->hFont) + SelectObject(hDC, hOldFont); + } + ReleaseDC(infoPtr->hwndEdit, hDC); + + labelSize.cx = infoPtr->nItemWidth; + labelSize.cy = infoPtr->nItemHeight; + + if (rcText.right != rcText.left) + labelSize.cx = min(rcText.right - rcText.left + TRAILING_LABEL_PADDING, infoPtr->nItemWidth); + + labelSize.cy = rcText.bottom - rcText.top; + + SetWindowPos(infoPtr->hwndEdit, NULL, 0, 0, labelSize.cx + 2, labelSize.cy + 2, + SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOZORDER); +} +#endif /*** * DESCRIPTION: * Subclassed edit control windproc function @@ -6190,7 +6236,13 @@ static LRESULT CALLBACK EditLblWndProcA(HWND hwnd, UINT uMsg, WPARAM wParam, LPA */ static HWND CreateEditLabelT(LISTVIEW_INFO *infoPtr, LPCWSTR text, BOOL isW) { +#ifdef __REACTOS__ + DWORD style = (infoPtr->uView == LV_VIEW_ICON) + ? (ES_AUTOVSCROLL | ES_MULTILINE | ES_CENTER | WS_CHILD | WS_VISIBLE | WS_BORDER) + : (ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER); +#else static const DWORD style = WS_CHILDWINDOW|WS_CLIPSIBLINGS|ES_LEFT|ES_AUTOHSCROLL|WS_BORDER|WS_VISIBLE; +#endif HINSTANCE hinst = (HINSTANCE)GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_HINSTANCE); HWND hedit; @@ -6297,9 +6349,22 @@ static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *infoPtr, INT nItem, BOOL isW) /* get string length in pixels */ GetTextExtentPoint32W(hdc, disptextW, lstrlenW(disptextW), &sz); +#ifndef __REACTOS__ /* add extra spacing for the next character */ GetTextMetricsW(hdc, &tm); sz.cx += tm.tmMaxCharWidth * 2; +#else + if (infoPtr->uView == LV_VIEW_ICON) + { + sz.cx = rect.right - rect.left + 4; + } + else + { + /* add extra spacing for the next character */ + GetTextMetricsW(hdc, &tm); + sz.cx += tm.tmMaxCharWidth * 2; + } +#endif if (infoPtr->hFont) SelectObject(hdc, hOldFont); @@ -12061,6 +12126,9 @@ static LRESULT LISTVIEW_Command(LISTVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lP { case EN_UPDATE: { +#ifdef __REACTOS__ + LISTVIEW_ResizeEdit(infoPtr); +#else /* * Adjust the edit window size */ @@ -12097,6 +12165,7 @@ static LRESULT LISTVIEW_Command(LISTVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lP ReleaseDC(infoPtr->hwndEdit, hdc); +#endif break; } case EN_KILLFOCUS: