如何在REALbasic中创建"选择文件夹或者文件对话框窗口"?

时间:2020-03-06 14:25:01  来源:igfitidea点击:

我们可以使用

SelectFolder()获取文件夹

或者

GetOpenFolderitem(过滤为字符串)以获取文件

但是我们可以选择文件夹还是文件? (或者为此选择多个文件)

解决方案

假设我们使用的是.Net,我认为我们需要创建自己的控件(或者购买一个控件)。

通过任何内置的API都是不可能的。可能有一个插件可以执行此操作,但是我不认为它对此提供了操作系统支持。

MonkeyBread插件在OpenDialogMBS类中允许此操作。

http://www.monkeybreadsoftware.net/pluginhelp/navigation-opendialogmbs.shtml

OpenDialogMBS.AllowFolderSelection as Boolean
property, Navigation, MBS Util Plugin (OpenDialog), class OpenDialogMBS, Plugin version: 7.5, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Whether folders can be selected.
Example: 
dim o as OpenDialogMBS
dim i,c as integer
dim f as FolderItem

o=new OpenDialogMBS
o.ShowHiddenFiles=true
o.PromptText="Select one or more files/folders:"
o.MultipleSelection=false
o.ActionButtonLabel="Open files/folders"
o.CancelButtonLabel="no, thanks."
o.WindowTitle="This is a window title."
o.ClientName="Client Name?"
o.AllowFolderSelection=true
o.ShowDialog

c=o.FileCount
if c>0 then
  for i=0 to c-1
    f=o.Files(i)

    FileList.List.AddRow f.AbsolutePath
  next
end if

Notes: 
Default is false.
Setting this to true on Windows or Linux has no effect there.
(Read and Write property)