gpt4 book ai didi

delphi - 枚举常量属性不流式传输

转载 作者:行者123 更新时间:2023-12-03 18:16:44 24 4
gpt4 key购买 nike

给定以下类型声明:

  TMyEnum = (onehundred,twohundred,threehundred);
TMyEnum2 = (Aonehundred = 100 , Atwohundred = 200 , Athreehundred = 300);

TMyComponent = class(TComponent)
private
FMyEnum: TMyEnum;
FMyEnum2: TMyEnum2;
published
property MyEnum: TMyEnum read FMyEnum write FMyEnum;
property MyEnum2: TMyEnum2 read FMyEnum2 write FMyEnum2;
end;

使用 TStream.WriteComponent 不会流式传输 MyEnum2。有谁知道这是为什么,如果可以解决?

最佳答案

很遗憾,这是流媒体系统的限制。 documentation说(强调我的):

Some properties, although publishable, are not fully supported by the streaming system. These include properties of record types, array properties of all publishable types, and properties of enumerated types that include anonymous values. If you publish a property of this kind, the Object Inspector will not display it correctly, nor will the property's value be preserved when objects are streamed to disk.

您无法轻松解决此问题,您需要提供自己的 custom streaming .

关于delphi - 枚举常量属性不流式传输,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11332004/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com