Export (0) Print
Expand All
MFC
Expand Minimize
0 out of 1 rated this helpful - Rate this topic

CListCtrl::GetColumnOrderArray 

Retrieves the column order (left to right) of a list view control.


BOOL GetColumnOrderArray(
   LPINT piArray,
   int iCount = -1 
);

Parameters

piArray

A pointer to a buffer that will contain the index values of the columns in the list view control. The buffer must be large enough to contain the total number of columns in the list view control.

iCount

Number of columns in the list view control. If this parameter is -1, the number of columns is automatically retrieved by the framework.

Nonzero if successful; otherwise zero.

This member function implements the behavior of the Win32 macro, ListView_GetColumnOrderArray, as described in the Platform SDK.

// The pointer to my list view control.
extern CListCtrl* pmyListCtrl;

// Reverse the order of the columns in the list view control
// (i.e. make the first column the last, the last column
// the first, and so on...).
CHeaderCtrl* pHeaderCtrl = pmyListCtrl->GetHeaderCtrl();

if (pHeaderCtrl != NULL)
{
   int  nColumnCount = pHeaderCtrl->GetItemCount();
   LPINT pnOrder = (LPINT) malloc(nColumnCount*sizeof(int));
   ASSERT(pnOrder != NULL);

   pmyListCtrl->GetColumnOrderArray(pnOrder, nColumnCount);

   int i, j, nTemp;
   for (i=0,j=nColumnCount-1;i < j;i++,j--)
   {
      nTemp = pnOrder[i];
      pnOrder[i] = pnOrder[j];
      pnOrder[j] = nTemp;
   }

   pmyListCtrl->SetColumnOrderArray(nColumnCount, pnOrder);
   free(pnOrder);
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.