Welcome to the forums!
I whipped up a little function. Enjoy.
Code:
typedef enum
{
SHOW_NO_ARROW,
SHOW_UP_ARROW,
SHOW_DOWN_ARROW
} SHOW_ARROW;
/*
* Description: Given a list-view control, this function will set the
* sort arrow for a specific column.
* Requirements: ComCtl32.dll Version 6 (available on XP and greater).
* To use Comctl32.dll version 6, you must specify it in a manifest.
* You also need to add: #define _WIN32_WINNT 0x501
* before including commctrl.h
* Example: xListViewSetSortArrow(hListView, 0, SHOW_UP_ARROW);
*/
BOOL xListViewSetSortArrow(HWND hListView, INT idxColumn, SHOW_ARROW showArrow)
{
HWND hHeader = NULL;
HDITEM hdrItem = { 0 };
hHeader = ListView_GetHeader(hListView);
if (hHeader)
{
hdrItem.mask = HDI_FORMAT;
if ( Header_GetItem(hHeader, idxColumn, &hdrItem) )
{
if (showArrow == SHOW_UP_ARROW)
{
hdrItem.fmt = (hdrItem.fmt & ~HDF_SORTDOWN) | HDF_SORTUP;
}
else if (showArrow == SHOW_DOWN_ARROW)
{
hdrItem.fmt = (hdrItem.fmt & ~HDF_SORTUP) | HDF_SORTDOWN;
}
else
{
hdrItem.fmt = hdrItem.fmt & ~(HDF_SORTDOWN | HDF_SORTUP);
}
return Header_SetItem(hHeader, idxColumn, &hdrItem);
}
}
return FALSE;
}
I think this may be possible for platforms prior to XP, but it is more complex and you would have to supply your own arrow images. There is a generic list-view sample that this function could be used with.