如何提取 TShellListView 中所选文件的名称?

发布于 2024-12-29 16:27:04 字数 319 浏览 1 评论 0原文

我查了一下有没有人问过这个问题,好像没有。我觉得这很奇怪,因为很容易从 TShellTreeView.Path 中提取路径,并且您可以获得完全限定的路径。

然而,我尽我所能在编辑器中查看类本身的所有属性和方法 - 没有文档 - 以及我能找到的唯一可能的字符串属性,其中 tlistitems 的标题是空白的。此外,“选定”属性结果为空白。

所以问题很简单,如何提取在 TShellListView 组件中选择的任何文件的名称。另外,我确实有四个 Shell 组件链接并工作,您可以选择一个驱动器,浏览目录结构,选择一个掩码并浏览到您想要的文件。

蒂亚·

安德鲁

I've done a good search to see if anyone else has asked this question, it seems not. I find this pretty strange as it is easy to extract the path From TShellTreeView.Path and you get the fully qualified path.

However I tried as hard as I could looking through all the properties and methods of the class itself in the editor - no documentation - and the only likely string properties I could find where the captions for the tlistitems, which turn out to be blank. Also the 'selected' property turns out to be blank.

So the question is simply, how can I extract the name of any file - or files - that are selected in a TShellListView component. Also I do have the four Shell components linked and working, you can choose a drive, browse the directory structure, choose a mask and browse to the file you want.

TIA

Andrew

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

各自安好 2025-01-05 16:27:04

如果您没有激活 MultiSelect 属性,请检查 SelectedFolder.PathName 属性,否则您可以迭代 Items 并检查 Selected 属性。

试试这个

function GetSelectedFiles(ShellListView : TShellListView) : TStringList;
var
  Index : Integer;
begin
  Result:=TStringList.Create;
  if not ShellListView.MultiSelect then
    Result.Add(ShellListView.SelectedFolder.PathName)
  else
  for Index := 0 to ShellListView.Items.Count-1 do
    if ShellListView.Items[Index].Selected AND (not ShellListView.Folders[Index].IsFolder) then
      Result.Add(ShellListView.Folders[Index].PathName);
end;

if you don't have activated the MultiSelect property check the SelectedFolder.PathName property, otherwise you can iterate over the Items and check the Selected property.

Try this

function GetSelectedFiles(ShellListView : TShellListView) : TStringList;
var
  Index : Integer;
begin
  Result:=TStringList.Create;
  if not ShellListView.MultiSelect then
    Result.Add(ShellListView.SelectedFolder.PathName)
  else
  for Index := 0 to ShellListView.Items.Count-1 do
    if ShellListView.Items[Index].Selected AND (not ShellListView.Folders[Index].IsFolder) then
      Result.Add(ShellListView.Folders[Index].PathName);
end;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文