Click to See Complete Forum and Search --> : 2 simple CListCtrl questions = )


Pipe
June 9th, 1999, 02:25 PM
hi,

actually, i have 2 questions.

1. given an index of an item in a list control (CListCtrl ). how do i highlite it?

i tried:

lvitem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
lvitem.state = LVIS_SELECTED | LVIS_FOCUSED;

as in my code below

lvitem.mask = LVIF_IMAGE | LVIF_TEXT;
lvitem.iItem = m_cactions_list.GetItemCount();
lvitem.iSubItem = 0;
lvitem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
lvitem.state = LVIS_SELECTED | LVIS_FOCUSED;

//other item setup here...

lvitem.pszText = key_hit;
actions_list.InsertItem( &lvitem );

i was thinking that it would set foucs/highlite to the last inserted item, but its not working.


2. given an index of an item in a list. how can i move it up or down in the list, ie. change its index?


thank you,
jeremy

Gary Grant
June 9th, 1999, 03:04 PM
Well for one thing:
vitem.mask = LVIF_IMAGE | LVIF_TEXT;
will have to be changed to
vitem.mask = LVIF_IMAGE | LVIF_TEXT|LVIF_STATE;
otherwise vitem.state will pretty much be ignored.

June 9th, 1999, 03:06 PM
1) Try changing "lvitem.iItem = m_cactions_list.GetItemCount()" to
"lvitem.iItem = m_cactions_list.GetItemCount() - 1" since iItem is zero based.

2) One of the articles in the Listview control section has a solution to this problem, but I do not remember which one it was.

Lee