I'm using a CListCtrl to display some items with icons in ListView Mode. Most of the time there is only one item in the list with plenty of space to the right, but on my Win2008 system (or Win7) it truncates the text using ellipsis (e.g. "Tank" is truncated to "Ta..."). This does not happen with all data (even some longer strings work), but repeatedly with the "Tank" example. Also on a WinXP system it works fine - always.
The list view is created via a rc file with
CONTROL "List2",IDC_LIST,"SysListView32",LVS_LIST | WS_BORDER | WS_TABSTOP,320,27,195,38
then it is instantiated
myListCtrl.SubclassDlgItem( IDC_LIST, this );
myListCtrl.ModifyStyle(LVS_OWNERDRAWFIXED, LVS_SHAREIMAGELISTS | LVS_SINGLESEL | LVS_SHOWSELALWAYS);
ListView_SetBkColor(myListCtrl.m_hWnd,PMAINFRM->GetColor(IDCOLOR_LI_BKG));
ListView_SetTextBkColor(myListCtrl.m_hWnd,PMAINFRM->GetColor(IDCOLOR_LI_BKG));
myListCtrl.SetImageList(PMAINFRM->GetImageList(IDICO_16),LVSIL_NORMAL);
myListCtrl.SetImageList(PMAINFRM->GetImageList(IDICO_16),LVSIL_SMALL);
I'm inserting only 1 column with the following format:
LV_COLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_SUBITEM;
lvc.fmt = LVCFMT_LEFT;
lvc.iSubItem = 0;
myListCtrl.InsertColumn(0,&lvc);
And the data is inserted
int index = 0;
int nItem = m_lstClass.InsertItem(index,(LPTSTR) strLabel, iIconID));
myListCtrl.SetItemData( nItem, (DWORD)index);
myListCtrl.SetItemState( nItem, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
I've tried
myListCtrl.SetColumnWidth(column, LVSCW_AUTOSIZE_USEHEADER);
as well as
myListCtrl.SetColumnWidth(column, LVSCW_AUTOSIZE);
And a
myListCtrl.SetExtendedStyle(LVS_EX_AUTOSIZECOLUMNS);
didn't do the trick either.
Any ideas?
Micha
I was pulling my hair out on this one as I had 2 identical CListCtrl's on the same dialog and one was showing the ellipsis and the other was not.
The issue in my case turned out to be that the items I was inserting had an appended newline character (10) as a result of reading the items from file with _fgetts(). Carriage return displayed the same issue.
The length of the item didn't matter, if it had a newline character then the last 2 characters would be stripped and replaced with ellipsis (although at least 1 character would be shown). The issue only manifested on Vista / Windows 7 and the server equivalents 2008, 2008 R2. I imagine Windows 8 and Server 2012 also show it but haven't yet tested that.
Stripping the newline character displayed the item in its full glory!