I use CListCtrl to display some items with icons in ListView mode. In most cases, there is only one element in the list with a lot of space to the right, but in my Win2008 (or Win7) system it cuts off the text using ellipsis (for example, "Tank" is truncated to "Ta ..."), This does not happen with all the data (even some longer lines work), but repeatedly with the example "Tank". It also works great on WinXP â always.
A list view is created via the rc file with
CONTROL "List2",IDC_LIST,"SysListView32",LVS_LIST | WS_BORDER | WS_TABSTOP,320,27,195,38
then it is created
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 insert 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 tried
myListCtrl.SetColumnWidth(column, LVSCW_AUTOSIZE_USEHEADER);
as well as
myListCtrl.SetColumnWidth(column, LVSCW_AUTOSIZE);
AND
myListCtrl.SetExtendedStyle(LVS_EX_AUTOSIZECOLUMNS);
didn't do the trick either.
Any ideas?
Micah