在Vista下使用Encodings组合框打开文件打开对话框 [英] File Open Dialog with Encodings combobox under Vista

查看:226
本文介绍了在Vista下使用Encodings组合框打开文件打开对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用的是TOpenTextFileDialog,因为它具有编码选项,但是在Vista下,它使用较旧的打开的对话框样式显示。我想要新的样式打开对话框,但使用编码组合框,我可以填充自定义字符串。基本上我想要在Vista下显示的记事本的确切的打开对话框。当然我也需要相应的保存对话框。

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.

我做了一些研究,似乎OFN_ENABLETEMPLATE标志导致Vista常见对话框回到旧样式。不幸的是,这也是标志,让TOpenTextFileDialog修改窗口来添加编码组合框(如果我理解正确的东西。)

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.)

有谁有一个建议如何获得什么我想在Vista下,但仍然在XP下工作?我假设Windows 7会有同样的问题。我正在使用D2009。感谢任何建议或帮助!

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!

推荐答案

与Vista一起处理文件对话框的新方法已经介绍,更多信息对于 IFileDialog 接口或查看这个博文。如你所说,使用 OFN_ENABLETEMPLATE 标志会导致Vista常用对话框回到旧样式。

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 the OFN_ENABLETEMPLATE flag causes the Vista common dialog to fall back to the old style.

使用Delphi 2007和2009,您可以在Vista对话框中使用 TFileOpenDialog TFileSaveDialog 类别。为了使您的应用程序与Vista之前的版本兼容,您应该继续使用 TOpenTextFileDialog ,并在运行时检查您是否在Vista上,并可以使用新的对话框: / p>

With Delphi 2007 and 2009 you can use the TFileOpenDialog and TFileSaveDialog in the Vista Dialogs components category. To make your application compatible with pre-Vista Windows versions you should keep using the TOpenTextFileDialog for those, and check at runtime whether you are on Vista and can use the new dialogs:

if Win32MajorVersion >= 6 then begin
  // use TFileOpenDialog
  // ...
end else begin
  // use TOpenTextFileDialog
  // ...
end;

现在您只需要将自定义添加到Vista对话框中。 博客帖子显示如何要做到这一点,通过添加对话框的 OnExecute 的处理程序(因为在这被称为 IFileDialog 接口已经设置),查询 IFileDialogCustomize 接口的文件对话框的对话框成员,并使用此添加附加控件。

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 the IFileDialog interface has been set up already), querying the Dialog member of the file dialog for the IFileDialogCustomize interface, and using this to add the additional controls.

这篇关于在Vista下使用Encodings组合框打开文件打开对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆