Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get selected item in ListView win32 API

I try to create list view item like explorer . I want to get the selected item when I double click on it .

So I can use it to get the path and find file to display . I can do it in treeview by senddlgmessage. But it looks like it doesn't work on listview .

like image 542
Dzung Nguyen Avatar asked Apr 22 '10 10:04

Dzung Nguyen


1 Answers

If you are just using a raw ListView control in C++, you need to do something like this:

// Get the first selected item
int iPos = ListView_GetNextItem(hListView, -1, LVNI_SELECTED);
while (iPos != -1) {
    // iPos is the index of a selected item
    // do whatever you want with it

    // Get the next selected item
    iPos = ListView_GetNextItem(hListView, iPos, LVNI_SELECTED);
}
like image 133
Grammarian Avatar answered Sep 24 '22 19:09

Grammarian