15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


CListCtrl Questions

Lance Lovette -- lovette@iftech.com
Wednesday, October 25, 1995

I've been playing with the CListCtrl class and have a few questions I can't
find answers for.  Either I'm missing these answers in the help or I've got
the wrong search string for the MSDN.

All these are related to the report view of the control.

1) How can you find the number of columns or subitems in a CListCtrl?

2) How can you get the header text of each column?

3) How can I make one column of the list 'stretchy' so all the columns add
   up to the exact width of the control?  Do the sums of all the
   GetColumnWidth's add up to the width of the client rectangle? There
   seems to be a magic number (I decided on 12) that has to be added to
   GetStringWidth to make the column wide enough to keep from truncating the
   string. Any tricks for this?

4) Can you get the HWND to the CHeaderCtrl that the CListCtrl is using?

Thanks,

Lance Lovette
lovette@iftech.com



Mike Blaszczak -- mikeblas@interserv.com
Wednesday, October 25, 1995

On Wed, 25 Oct 1995, Lance Lovette  wrote:
>I've been playing with the CListCtrl class and have a few questions I can't
>find answers for.  Either I'm missing these answers in the help or I've got
>the wrong search string for the MSDN.
>
>All these are related to the report view of the control.

>4) Can you get the HWND to the CHeaderCtrl that the CListCtrl is using?

This question answers all of your others: you can get the header control in a 
list view control using the report view by doing this:

   CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_YOURLISTVIEW);
   ASSERT(pListCtrl != NULL);
   CHeaderCtrl* pHeaderCtrl = (CHeaderCtrl*) pListCtrl->GetDlgItem(0);
   ASSERT(pHeaderCtrl != NULL);

So, for example, you could get the text from each of the items with code like 
this:

   int nColCount = pHeaderCtrl->GetItemCount();
   int nIndex;
   TCHAR szBuffer[255];
   HD_ITEM hdi;
   hdi.mask = HDI_TEXT;
   hdi.pszText = szBuffer;
   hdi.cchTextMax = 255;

   for (nIndex = 0; nIndex < nColCount; nIndex++)
   {
      if (pHeaderCtrl->GetItem(nIndex, &hdi))
         TRACE(_T("Item %d is \"%s\"\n"), nIndex, szBuffer);
   }

.B ekiM
--
#ifdef JOHNELS_SAID_I_COULD_STEAL_HIS_SIG
TCHAR szDisc[] = _T("These words are my own; I do not speak for Microsoft.");
#endif




Jason Landry -- jlandry@infosense.com
Wednesday, April 10, 1996

Platform:
  Win 95, 32 meg RAM
  VC++ 4.1
  Developing for Win 95 Only

I have a CFormView that has a couple of CListCtrl's on it.
Each of these lists may contain a couple of hundred items.

When my application first loads, it does an InsertItem to
populate the list, but it seems to take forever.  I have
turned off screen drawing until the entire list is filld,
which improved things, but it still takes about 3-4 seconds
to fill the list on a P90.  Is there any way to add
a bunch of items in a batch??

Thanks for any help

Jason Landry



Steven Youngs -- steve@ncgraphics.co.uk
Monday, April 15, 1996

On 10 April 1996 15:08, Jason Landry wrote:
>Platform:
>  Win 95, 32 meg RAM
>  VC++ 4.1
>  Developing for Win 95 Only
>
>I have a CFormView that has a couple of CListCtrl's on it.
>Each of these lists may contain a couple of hundred items.
>
>When my application first loads, it does an InsertItem to
>populate the list, but it seems to take forever.  I have
>turned off screen drawing until the entire list is filld,
>which improved things, but it still takes about 3-4 seconds
>to fill the list on a P90.  Is there any way to add
>a bunch of items in a batch??
>
Have you called pMyListCtrl->SetItemCount(nItems) where nItems is 
the number of items in the populated list?

Steve.
_____________
Steven Youngs
NC Graphics (Cambridge) Ltd.




| Вернуться в корень Архива |