Delphi FireMonkey中的TFileOpenDialog如何实现长尾词功能?
- 内容介绍
- 文章标签
- 相关推荐
本文共计227个文字,预计阅读时间需要1分钟。
我目前正在使用FireMonkey,并希望用户能通过TFileOpenDialog提供的接口选择目录。我发现SelectDirectory接口最好用,即使用sdNewUI选项。首先,确保在FireMonkey应用程序中包含VCL.Dialogs单元(使用TFil)。
我正在使用FireMonkey并希望用户使用TFileOpenDialog提供的接口选择目录(我发现SelectDirectory接口最好过时 – 是的,即使使用sdNewUI选项).首先,在FireMonkey应用程序中包含VCL.Dialogs单元(使用TFileOpenDialog)是不好的做法吗?
其次,这仍然只适用于Windows Vista及更高版本.这是检查兼容Windows版本的正确方法吗?
{IFDEF WIN32 or WIN64} if Win32MajorVersion >= 6 then // Create TOpenFileDialog with fdoPickFolders option 为了将来参考,使用IFileDialog创建Windows Vista及以上文件夹对话框:
uses ShlObj, ActiveX; ... var FolderDialog : IFileDialog; hr: HRESULT; IResult: IShellItem; FileName: PChar; Settings: DWORD; begin if Win32MajorVersion >= 6 then begin hr := CoCreateInstance(CLSID_FileOpenDialog, nil, CLSCTX_INPROC_SERVER, IFileDialog, FolderDialog); if hr = S_OK then begin FolderDialog.GetOptions(Settings); FolderDialog.SetOptions(Settings or FOS_PICKFOLDERS); FolderDialog.GetOptions(Settings); FolderDialog.SetOptions(Settings or FOS_FORCEFILESYSTEM); FolderDialog.SetOkButtonLabel(PChar('Select')); FolderDialog.SetTitle(PChar('Select a Directory')); hr := FolderDialog.Show(Handle); if hr = S_OK then begin hr := FolderDialog.GetResult(IResult); if hr = S_OK then begin IResult.GetDisplayName(SIGDN_FILESYSPATH,FileName); ConfigPathEdit.Text := FileName; end; end; end; end; end;
本文共计227个文字,预计阅读时间需要1分钟。
我目前正在使用FireMonkey,并希望用户能通过TFileOpenDialog提供的接口选择目录。我发现SelectDirectory接口最好用,即使用sdNewUI选项。首先,确保在FireMonkey应用程序中包含VCL.Dialogs单元(使用TFil)。
我正在使用FireMonkey并希望用户使用TFileOpenDialog提供的接口选择目录(我发现SelectDirectory接口最好过时 – 是的,即使使用sdNewUI选项).首先,在FireMonkey应用程序中包含VCL.Dialogs单元(使用TFileOpenDialog)是不好的做法吗?
其次,这仍然只适用于Windows Vista及更高版本.这是检查兼容Windows版本的正确方法吗?
{IFDEF WIN32 or WIN64} if Win32MajorVersion >= 6 then // Create TOpenFileDialog with fdoPickFolders option 为了将来参考,使用IFileDialog创建Windows Vista及以上文件夹对话框:
uses ShlObj, ActiveX; ... var FolderDialog : IFileDialog; hr: HRESULT; IResult: IShellItem; FileName: PChar; Settings: DWORD; begin if Win32MajorVersion >= 6 then begin hr := CoCreateInstance(CLSID_FileOpenDialog, nil, CLSCTX_INPROC_SERVER, IFileDialog, FolderDialog); if hr = S_OK then begin FolderDialog.GetOptions(Settings); FolderDialog.SetOptions(Settings or FOS_PICKFOLDERS); FolderDialog.GetOptions(Settings); FolderDialog.SetOptions(Settings or FOS_FORCEFILESYSTEM); FolderDialog.SetOkButtonLabel(PChar('Select')); FolderDialog.SetTitle(PChar('Select a Directory')); hr := FolderDialog.Show(Handle); if hr = S_OK then begin hr := FolderDialog.GetResult(IResult); if hr = S_OK then begin IResult.GetDisplayName(SIGDN_FILESYSPATH,FileName); ConfigPathEdit.Text := FileName; end; end; end; end; end;

