Discussion:
Virtual Listview DeleteItem ProblemsPB/Win 8.01
(too old to reply)
Dankert
2006-04-22 05:58:23 UTC
Permalink
Hello,

x = ListView_GetSelectionMark(hCtl) 'x contains the correct index number
of the item to be deleted
ListView_DeleteItem(hCtl,x) 'The item which get deleted is always item x
+ 2.

Have someone else encounter this before?

Thanks for your attention.
--
Dankert
Michael Mattias
2006-04-22 13:36:22 UTC
Permalink
Post by Dankert
Hello,
x = ListView_GetSelectionMark(hCtl) 'x contains the correct index number
of the item to be deleted
ListView_DeleteItem(hCtl,x) 'The item which get deleted is always item x
+ 2.
If, as your subject line suggests, this is a VIRTUAL listview, you don't
delete items from it, you use ListView_SetItemCountEx to reduce by one the
number of items and adjust the contents of whatever you are using to
provide the item text when the control asks for it. A real virtual ("real
virtual?" That's sure oxymoronic!) listview is one created with style
LVS_OWNERDATA. But you don't show the actual styles used; and in this case
it really really makes a difference.

Further, the GetSelectionMark function itself.... I've have problems with
it, so I just use ListView_FindNextItem hCtrl, -1&, LVNI_SELECTED to find
the index of the first selected item. I think the problems are related to
the fact that GetSelectionMark was designed to find the first selection of
multiple selections, not "THE" selected item.

MCM
Dankert
2006-04-22 16:22:18 UTC
Permalink
Post by Michael Mattias
Post by Dankert
Hello,
x = ListView_GetSelectionMark(hCtl) 'x contains the correct index number
of the item to be deleted
ListView_DeleteItem(hCtl,x) 'The item which get deleted is always item
x
Post by Dankert
+ 2.
If, as your subject line suggests, this is a VIRTUAL listview, you don't
delete items from it, you use ListView_SetItemCountEx to reduce by one the
number of items and adjust the contents of whatever you are using to
provide the item text when the control asks for it. A real virtual ("real
virtual?" That's sure oxymoronic!) listview is one created with style
LVS_OWNERDATA. But you don't show the actual styles used; and in this case
it really really makes a difference.
Yes, it is created with the %LVS_OWNERDATA style.
Post by Michael Mattias
Further, the GetSelectionMark function itself.... I've have problems with
it, so I just use ListView_FindNextItem hCtrl, -1&, LVNI_SELECTED to find
the index of the first selected item. I think the problems are related to
the fact that GetSelectionMark was designed to find the first selection of
multiple selections, not "THE" selected item.
MCM
Thanks, I'll try this approach next time I'm in need of a virtual
listview.Right now a none virtual listview can do, so I changed it to a such
one.
--
Dankert

Loading...