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 had this problem, and I think I have finally found the answer. The problem in my case was that the dialog had a font specified in this style:
If I removed the
FONTline and theDS_SETFONTflag,CListCtrlstarted showing the text without truncation again.My assumption is that it is using different fonts to measure the width of the text and actually do the drawing, this is causing the truncation.