[section_title title=Run-down]

The ListView control uses the Header control to display the header columns. Don’t worry, in our case we are concerned with only two of the several messages that it supports, and I will explain what we will be doing. Here is a quick run-down.

  1. First we have to get a pointer to the header control using the LVM_GETHEADER message.
  2. If we are sorting a new column, i.e. previously we sorted by column 1 and now we are sorting by column 2 then we will have to first remove the icon from the previous column (assuming we are only supporting sorting on one column at a time). See the next step on how this is done.
  3. We set the icon on the new column in three steps.
    1. Using the HDITEM structure with mask set to HDI_FORMAT and HDM_GETITEM message we will get the current format.
    2. Append either HDF_SORTUP or HDF_SORTDOWN to the fmt parameter.
    3. Send HDM_SETITEM message to set the new icon.