新的TFileOpenDialog和旧的TOpenDialog有什么区别? [英] What is the difference between the new TFileOpenDialog and the old TOpenDialog?

查看:881
本文介绍了新的TFileOpenDialog和旧的TOpenDialog有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的TFileOpenDialog和旧的TOpenDialog有什么区别?

在我的电脑(Win 7 / DXE)中,当我运行代码时,对话框看起来一样。

解决方案


  • TOpenDialog 包装传统的 GetOpenFileName 。它适用于所有版本的Windows。

  • TFileOpenDialog 包装在Vista中引入的新的基于COM的对话框。因此它只适用于Vista或更高版本。它具有比旧版对话框更多的功能,最显着的是与搜索紧密集成。



Vista常用对话框



兼容性常见对话框



如果调用正确的话,大多数情况下, GetOpenFileName API将会产生新的对话框,所以实际上不能区分出差异。也就是说,历史上,VCL的包装器 GetOpenFileName 被不精确地实现,并且始终导致显示兼容性对话框。



但是,新的COM对话框提供了什么?



新的对话框提供了一个更简单的自定义界面,因为失去了一些通用性。如果您在Vista或更高版本上使用具有 GetOpenFileName 的旧对话框模板定制,则对话框将降级为缺乏功能的丑版兼容性版本。



新对话框的另一大优点是能够选择无限数量的文件。旧的 GetOpenFileName 接口在固定大小的缓冲区中返回多选文件名。这可能是一个真正的限制,在我自己的代码中,我不得不劫持VCL代码,使得当我的应用程序在XP上运行时,缓冲区更大。



TOpenDialog 将可能将工作委托给 TFileOpenDialog 。它使用的测试需要以下所有条件:




  • 在Windows Vista或更高版本上运行。

  • Dialogs.UseLatestCommonDialogs global boolean variable为true(默认为true)。

  • 没有指定对话框模板。

  • OnIncludeItem OnClose OnShow 事件都没有分配。大概这些不能被 TFileOpenDialog 触发。



strong>



如果您继续使用 TOpenDialog ,那么您将获得无限数量的文件,选择模式。但是,如果您希望自定义对话框,并且有新的对话框,而不是丑陋的兼容性对话框,则需要执行以下操作:




  • 在XP上使用 TOpenDialog 和对话框模板方法。

  • 在Vista上,稍后使用 TFileOpenDialog 并使用 IFileDialogCustomize 实现定制。


What is the difference between the new TFileOpenDialog and the old TOpenDialog?
In my computer (Win 7/DXE), when I run the code, the dialogs look the same.

解决方案

  • TOpenDialog wraps the traditional GetOpenFileName. It works on all versions of Windows.
  • TFileOpenDialog wraps the new COM based dialog that was introduced in Vista. It therefore only works on Vista or later. It has more functionality than the older dialogs, most notably the tight integration with search.

Vista common dialog

Compatibility common dialog

The GetOpenFileName API will in fact produce the new dialogs in most situations, if called correctly, so you can't actually tell the difference. That said, historically the VCL's wrapper for GetOpenFileName was implemented imprecisely and always resulted in the compatibility dialog being shown.

But what does the new COM dialog have to offer then?

The new dialog offers a much easier customisation interface at the loss of some generality. If you use the old dialog template based customisation with GetOpenFileName on Vista or later then the dialogs degrade to ugly compatibility versions that lack functionality.

The other big advantage of the new dialogs is the ability to select unlimited number of files. The old GetOpenFileName interface returned multi-select filenames in a fixed size buffer. This can be a real limitation and in my own code I have had to hack the VCL code to make this buffer larger for when my app runs on XP.

TOpenDialog will delegate the work to TFileOpenDialog if possible. The test it uses requires all of the following to be true:

  • Running on Windows Vista or later.
  • Dialogs.UseLatestCommonDialogs global boolean variable is true (default is true). This allows you to disable the use of the new COM dialog should you elect to do so.
  • No dialog template is specified.
  • OnIncludeItem, OnClose and OnShow events are all not assigned. Presumably these cannot be fired by TFileOpenDialog.

Summary

If you continue to use TOpenDialog then you will reap the benefit of unlimited number of file in multi-select mode. However, if you wish to customise the dialog, and have the new dialogs rather than the ugly compatibilty dialogs, then you need to do the following:

  • On XP use TOpenDialog and the dialog template method.
  • On Vista and later use TFileOpenDialog and implement customisation with IFileDialogCustomize.

这篇关于新的TFileOpenDialog和旧的TOpenDialog有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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