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 Windows SDK.
Example
// 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 = m_myListCtrl.GetHeaderCtrl();
if (pHeaderCtrl != NULL)
{
int nColumnCount = pHeaderCtrl->GetItemCount();
LPINT pnOrder = (LPINT) malloc(nColumnCount*sizeof(int));
ASSERT(pnOrder != NULL);
m_myListCtrl.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;
}
m_myListCtrl.SetColumnOrderArray(nColumnCount, pnOrder);
free(pnOrder);
}
Requirements
Header: afxcmn.h
See Also
Reference
CListCtrl::SetColumnOrderArray