How to add items to an MFC CListCtrl object so their icons appear in top-to-bottom sequence?
Domanda
I'm using Visual Studio C++ 2008 v 3.5 SP1 (with Feature Pack).
After adding items to an MFC CListCtrl
object via InsertItem()
, their icons appear in reverse row order, but correct column order, in most of the view modes.
I'm not using "report" (LV_VIEW_DETAILS
) mode, so the rows and columns I mention refer to how the icons are sequenced within a grid or layout.
I add them like this:
for (int i = 0; i < item_count; ++i)
list_ctrl.InsertItem (i, item_arr[i].text, i);
and would like them to appear like this:
icon 0
icon 1
icon 2
:
icon N-2
icon N-1
(where icon # matches its item # and N is item_count
).
However, in "large icon", "small icon" and "tile" (LV_VIEW_ICON
, LV_VIEW_SMALLICON
, LV_VIEW_TILE
) modes, they appear like this:
icon N-1
icon N-2
:
icon 2
icon 1
icon 0
They only appear in correct sequence in "list" (LV_VIEW_LIST
) mode, but then they arrange and scroll horizontally:
icon 0 icon 1 icon 2 .. icon N-2 icon N-1
(Whether they appear all in a single row/column is merely a function of the relative size/dimension of the icons and the control.) It seems I can have vertical orientation but reverse order, or correct order but wrong orientation!
How do I get things the way I want? I've seen nothing in the docs or in forums about this -- only about sorting items by text (which I don't want) or sorting the order of columns in details/report mode (which I don't want).
Soluzione
After spending too much time we finally figured it out:
I needed to change the OwnerDrawFixed
property (back) to False
!
Now it works as expected.