{"id":427,"date":"2008-05-03T09:12:06","date_gmt":"2008-05-03T09:12:06","guid":{"rendered":"http:\/\/6teen.ru\/?p=678"},"modified":"2008-05-03T09:12:06","modified_gmt":"2008-05-03T09:12:06","slug":"7436","status":"publish","type":"post","link":"http:\/\/pblog.ru\/lab\/?p=427","title":{"rendered":"\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f MultiSelect \u0432 ShellListView"},"content":{"rendered":"<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f MultiSelect \u0432 ShellListView<br \/>\n<!--more--><\/p>\n<pre class=\"alt2\" style=\"margin:0px; padding:6px; border:1px inset; width:580px; height:320px; overflow:auto\"><div>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f MultiSelect \u0432 ShellListView\n\nShellListView does not have a files property (common in dialogs eg TOpendialog),\ntherefore we have to cycle through each item to find out whether the\nitem is selected or not.\n\nUse this function to obtain a list of selected files in a ShellListView:\nfunction SelectedFiles(AShellView: TShellListView): TStringList;\nbegin\nResult := TStringList.Create;\nfor i := 0 to shelllistview1.Items.Count - 1 do\n\/\/ is the item selected?\nif shelllistview1.Items[i].Selected = True then\n\/\/ Folders can also refer to files, which is why we check isFolder\n\/\/ before adding the filepath to the result\nif shelllistview1.folders[i].IsFolder = False then\n\/\/ add filepath and filename to result\nResult.Add(shelllistview1.Folders[i].PathName);\n\nend;\n\n\/\/ ---------- \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 -------------------------------------------------\n\nprocedure TForm1.Button1Click(Sender: TObject);\nvar\ni: Integer;\nFileList: TStringList;\nbegin\ntry\nFileList := TStringList.Create; \/\/create stringlist to contain filenames\nFileList := SelectedFiles(ShellListView1); \/\/populate tstringlist\n\nif FileList.Count = 0 then Exit; \/\/exit if no files selected\n\nfor i := 0 to FileList.Count - 1 do\nShowMessage(FileList[i]); \/\/cycle through each filename and do something\nfinally\nFreeAndNil(FileList); \/\/free tstringlist when finished\nend;\nend;\n\n<\/div><\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f MultiSelect \u0432 ShellListView<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[423,386],"tags":[549,1920,1678],"_links":{"self":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/427"}],"collection":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=427"}],"version-history":[{"count":0,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/427\/revisions"}],"wp:attachment":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=427"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}