Export (0) Print
Expand All
Expand Minimize

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.

Return Value

Nonzero if successful; otherwise zero.

Remarks

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

Example

// 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);
}

See Also

CListCtrl Overview | Class Members | Hierarchy Chart | CListCtrl::SetColumnOrderArray

Show:
© 2014 Microsoft