我目前使用 TOpenTextFileDialog,因为它具有编码选项,但在 Vista 下,它显示为使用旧的打开对话框样式。 我想要新样式的打开对话框,但带有一个可以用自定义字符串填充的编码组合框。 基本上我想要记事本在 Vista 下显示的完全相同的打开对话框。 当然我还需要相应的保存对话框。
我做了一些研究,似乎 OFN_ENABLETEMPLATE 标志导致 Vista 通用对话框回退到旧样式。 不幸的是,这也是让 TOpenTextFileDialog 修改窗口以添加编码组合框的标志(如果我理解正确的话)。
有没有人建议如何在 Vista 下获得我想要的内容,但仍然可以在 XP 下工作? 我认为 Windows 7 也会有同样的问题。 我用的是D2009。 感谢您的任何建议或帮助!
I currently use the TOpenTextFileDialog as it has the Encodings option, but under Vista it appears using the older open dialog style. I'd like the new style open dialog, but with an encoding combobox that I can fill with custom strings. Basically I want the exact open dialog that Notepad shows under Vista. Of course I also need the corresponding save dialog as well.
I've done some research and it seems that the OFN_ENABLETEMPLATE flag causes the Vista common dialog to fall back to the old style. Unfortunately that's also the flag that lets the TOpenTextFileDialog modify the window to add the encodings combobox (if I understand things properly.)
Does anyone have a suggestion on how to get what I want under Vista but still have it work under XP? I assume that Windows 7 will have the same issue. I'm using D2009. Thanks for any suggestions or help!
发布评论
评论(1)
Vista 引入了一种处理文件对话框的新方法,有关更多信息,请谷歌搜索
IFileDialog
界面或查看 这篇博文。 正如您自己所说,使用OFN_ENABLETEMPLATE
标志会导致 Vista 通用对话框回退到旧样式。在 Delphi 2007 和 2009 中,您可以使用 Vista 对话框 组件类别中的
TFileOpenDialog
和TFileSaveDialog
。 为了使您的应用程序与 Vista 之前的 Windows 版本兼容,您应该继续使用TOpenTextFileDialog
,并在运行时检查您是否在 Vista 上并且可以使用新的对话框:现在您只需添加定制 Vista 对话框。 博客文章展示了如何为此,通过添加对话框的
OnExecute
处理程序(因为在调用此方法时,已设置了IFileDialog
接口),查询IFileDialogCustomize
接口的文件对话框的 >Dialog 成员,并使用它来添加其他控件。With Vista a new way of dealing with file dialogs has been introduced, for more information google for the
IFileDialog
interface or have a look at this blog post. As you say yourself, using theOFN_ENABLETEMPLATE
flag causes the Vista common dialog to fall back to the old style.With Delphi 2007 and 2009 you can use the
TFileOpenDialog
andTFileSaveDialog
in the Vista Dialogs components category. To make your application compatible with pre-Vista Windows versions you should keep using theTOpenTextFileDialog
for those, and check at runtime whether you are on Vista and can use the new dialogs:Now you only need to add the customization to the Vista dialog. The blog post shows how to do this, by adding a handler for
OnExecute
of the dialog (because at the time when this is called theIFileDialog
interface has been set up already), querying theDialog
member of the file dialog for theIFileDialogCustomize
interface, and using this to add the additional controls.