本文介绍了有没有更简单的说法说所有平台都支持Delphi组件/控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了使Delphi组件/控件可用于所有(当前)可用平台,我必须编写

In order to make Delphi component/control available for all (currently) available platforms I have to write

  [ComponentPlatforms(pidWin32 or pidWin64 or pidOSX32 or pidiOSSimulator or pidiOSDevice or pidAndroid)]

在组件/控件声明之前:

before component/control declaration:

type
  [ComponentPlatforms(pidWin32 or ...)]
  TMyComponent = class(TComponent)
  end;

组件是否支持所有当前和将来的平台的书写方式较短? >?

Is there a shorter way of writing that component supports all current and future platforms?

推荐答案

没有更简单的方法,但是您可以将它们定义为一个常量:

There is no simpler way, but you could define those as one constant:

const
  AllCurrentPlatforms = 
    pidWin32 or pidWin64 or pidOSX32 or 
    pidiOSSimulator or pidiOSDevice or pidAndroid;

,并在每次创建新组件时使用它。但是,假设您不生产那么多组件,那么将其全部写出来又有什么问题呢?需要几次?

and use that each time you create a new component. But, assuming you don't produce that many components, what is wrong with writing it out in full, the few times it is needed?

我还假设如果您只需忽略该属性,该组件将被视为支持所有平台。您可以测试一下。

I also assume that if you simply omit the attribute, the component will be considered as supporting all platforms. You could test that.

实际上还有一个类似的常量 AllPlatforms 在ToolsAPI / PlatformAPI中,但该单元不适用于常规运行时。

There is actually a similar constant AllPlatforms in ToolsAPI/PlatformAPI but that unit is not for general runtime use.

这篇关于有没有更简单的说法说所有平台都支持Delphi组件/控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 16:33