Hi guys,
this is a minor question but I just don't find the answer on MSDN or google.
How do I activate the small arrow (for sorting) in the head of the column in a
listview? I am using plain C, no MFC etc. (Mingw + gcc).
Thanks
Thomas
This is a discussion on Listview arrow in column head within the Windows Programming forums, part of the Platform Specific Boards category; Hi guys, this is a minor question but I just don't find the answer on MSDN or google. How do ...
Hi guys,
this is a minor question but I just don't find the answer on MSDN or google.
How do I activate the small arrow (for sorting) in the head of the column in a
listview? I am using plain C, no MFC etc. (Mingw + gcc).
Thanks
Thomas
I looked for exact the same thing a while ago. I found an aswer, but it was so much trouble to implement, i didnt add it. Unfortunately i dont remember where i found the answer.
Welcome to the forums!
I whipped up a little function. Enjoy.
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.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; }
Thanks, I think that will help