简体   繁体   English

在ListView win32 API中获取所选项目

[英]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. 我可以通过senddlgmessage在treeview中完成它。 But it looks like it doesn't work on listview . 但看起来它在listview上不起作用。

If you are just using a raw ListView control in C++, you need to do something like this: 如果您只是在C ++中使用原始ListView控件,则需要执行以下操作:

// 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);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM