This documentation is archived and is not being maintained.


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

BOOL GetColumnOrderArray(
   LPINT piArray,
   int iCount = -1 


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.


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 Windows SDK.

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

Header: afxcmn.h