是否可以使用 TOpenDialog select a folder/directory?
Is it possible to select a folder/directory using TOpenDialog?
我看过这个问题:Selecting a directory with TOpenDialog
技术上没有回答(OP 特别询问了 TOpenDialog - 而不是 TFileOpenDialog)但适用于更高版本的 Delphi。
我正在使用 Delphi 7,所以 TFileOpenDialog 不可用。
那么可以使用 TOpenDialog select 文件夹吗?
我知道 SelectDirectory 并看过其他关于它的帖子,我也知道 BrowseFolder。
我只对与 TOpenDialog 相关的答案感兴趣。
我尝试将文件名 属性 设置为“*”。正如某人在某处建议的那样,但这不起作用。
I've seen this question: Selecting a directory with TOpenDialog
Which technically is NOT answered
它是,无论如何在其中一条评论中:
"TFileOpenDialog != TOpenDialog ... TOpenDialog 没有这样的选项"
这就是答案。
I'm using Delphi 7 so TFileOpenDialog is not available.
不,不是。然而,它在内部使用的底层 IFileDialog
and IFileOpenDialog
接口是标准的 Win32 COM 接口(仅在 Vista+ 上),因此它们可以在 Delphi 7 中使用,只要你有它们的声明你的代码。
So is it possible to use TOpenDialog to select a folder?
简短的回答是否。
在 Delphi 7 中,TOpenDialog
只是 Win32 API GetOpenFileName()
function, which can only select and return files, not folders. You must use SelectDirectory()
(which is just a wrapper for the Win32 API SHBrowseForFolder()
函数的包装,如果您使用较新的重载),或者 IFileDialog
/IFileOpenDialog
启用 FOS_PICKFOLDERS
选项。
在 Delphi 的现代版本中,TOpenDialog
会尽可能委托给 Vista+ 上的 IFileDialog
/IFileOpenDialog
(启用主题,不使用不公开的旧 VCL 功能通过较新的对话框等),但它不会启用 FOS_PICKFOLDERS
选项。
我看过这个问题:Selecting a directory with TOpenDialog
技术上没有回答(OP 特别询问了 TOpenDialog - 而不是 TFileOpenDialog)但适用于更高版本的 Delphi。
我正在使用 Delphi 7,所以 TFileOpenDialog 不可用。
那么可以使用 TOpenDialog select 文件夹吗?
我知道 SelectDirectory 并看过其他关于它的帖子,我也知道 BrowseFolder。
我只对与 TOpenDialog 相关的答案感兴趣。
我尝试将文件名 属性 设置为“*”。正如某人在某处建议的那样,但这不起作用。
I've seen this question: Selecting a directory with TOpenDialog
Which technically is NOT answered
它是,无论如何在其中一条评论中:
"TFileOpenDialog != TOpenDialog ... TOpenDialog 没有这样的选项"
这就是答案。
I'm using Delphi 7 so TFileOpenDialog is not available.
不,不是。然而,它在内部使用的底层 IFileDialog
and IFileOpenDialog
接口是标准的 Win32 COM 接口(仅在 Vista+ 上),因此它们可以在 Delphi 7 中使用,只要你有它们的声明你的代码。
So is it possible to use TOpenDialog to select a folder?
简短的回答是否。
在 Delphi 7 中,TOpenDialog
只是 Win32 API GetOpenFileName()
function, which can only select and return files, not folders. You must use SelectDirectory()
(which is just a wrapper for the Win32 API SHBrowseForFolder()
函数的包装,如果您使用较新的重载),或者 IFileDialog
/IFileOpenDialog
启用 FOS_PICKFOLDERS
选项。
在 Delphi 的现代版本中,TOpenDialog
会尽可能委托给 Vista+ 上的 IFileDialog
/IFileOpenDialog
(启用主题,不使用不公开的旧 VCL 功能通过较新的对话框等),但它不会启用 FOS_PICKFOLDERS
选项。