CMFCListctrl Sorting

Viewed 488

In CMFCListCtrl, I am adding sorting arrow image in the header by calling the function SetSortColumn().

Now the problem is when sort arrow image is getting displayed, the header text is not getting visible fully.

How to adjust/expand the size of header programmatically on displaying sort arrow?

img1

img2

1 Answers

The internal code shows that the item height of the header control -5 is used for the room of the sort symbol.

see CMFCHeaderCtrl::OnDrawItem.

    // Draw sort arrow:
    CRect rectArrow = rect;
    rectArrow.DeflateRect(5, 5);
    rectArrow.left = rectArrow.right - rectArrow.Height();

So enlarging all items by this size will help.

This should work. Calculate the height of of use font, multiply by 1.5 and add this to the width of the column.

Related