Update nItemWidth in LISTVIEW_SetItem() if LVS_LIST or LVS_SMALLICON

mode and item text is wider than the current nItemWidth.
This commit is contained in:
Chris Morgan 2000-05-19 03:44:46 +00:00 committed by Alexandre Julliard
parent f2f0927eb3
commit 9a171b8e3e

View File

@ -138,6 +138,7 @@ static HWND LISTVIEW_EditLabelA(HWND hwnd, INT nItem);
static BOOL LISTVIEW_EndEditLabel(HWND hwnd, LPSTR pszText, DWORD nItem);
static LRESULT LISTVIEW_Command(HWND hwnd, WPARAM wParam, LPARAM lParam);
static LRESULT LISTVIEW_SortItems(HWND hwnd, WPARAM wParam, LPARAM lParam);
static LRESULT LISTVIEW_GetStringWidthA(HWND hwnd, LPCSTR lpszText);
/*************************************************************************
* LISTVIEW_UpdateHeaderSize [Internal]
@ -1652,8 +1653,11 @@ static BOOL LISTVIEW_SetItem(HWND hwnd, LPLVITEMA lpLVItem)
HDPA hdpaSubItems;
LISTVIEW_ITEM *lpItem;
NMLISTVIEW nmlv;
UINT uChanged;
LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID);
LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
UINT uChanged;
UINT uView = lStyle & LVS_TYPEMASK;
INT item_width;
if (lpLVItem != NULL)
{
@ -1688,6 +1692,16 @@ static BOOL LISTVIEW_SetItem(HWND hwnd, LPLVITEMA lpLVItem)
/* copy information */
bResult = LISTVIEW_InitItem(hwnd, lpItem, lpLVItem);
/* if LVS_LIST or LVS_SMALLICON, update the width of the items based on */
/* the width of the items text */
if((uView == LVS_LIST) || (uView == LVS_SMALLICON))
{
item_width = LISTVIEW_GetStringWidthA(hwnd, lpItem->pszText);
if(item_width > infoPtr->nItemWidth)
infoPtr->nItemWidth = item_width;
}
/* send LVN_ITEMCHANGED notification */
nmlv.hdr.code = LVN_ITEMCHANGED;
ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv);