Delphi XE2中的TDataModule.ClassGroup伪属性是做什么的? [英] What does TDataModule.ClassGroup pseudo-property in Delphi XE2 really do?

查看:711
本文介绍了Delphi XE2中的TDataModule.ClassGroup伪属性是做什么的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Delphi XE2中将组件从一个数据模块复制并粘贴到另一个数据模块中。该组件是一个快速报告数据源链接组件。数据模块是全新的,刚刚在XE2中创建了第二个。



其他人也有同样的问题,并在质量中心为106369 和同样的错误信息导致我这个神秘的DocWiki条目



所以数据模块现在有一个框架关联性,一个设计时间的伪属性,根据文档:



因为ClassGroup伪属性仅由IDE使用,而不是编译器生成的属性(因此是伪属性),编译器中没有记录ClassGroup所发布的图书馆参考,您正在阅读的页面是ClassGroup的文档。



所以,我第一次学习这个存在是当它阻止我从副本和从我不想r的一组现有的设计时间构建块中将组件粘贴到我的数据模块中ebuild从零开始。



一旦我更改了数据模块的亲和力,我可以将数据粘贴到数据模块中,而不会让我发生错误。感谢Google的善意 - 那个错误,或者我会被困住。



如果它旨在帮助我们编写跨平台数据模块,但它只影响IDE根据文档,这与您在设计时使用此设置时发生的警告不一致,以下是更改错误时:

  EInvalidType:以下组件在指定的
类组中不可用。这很可能导致编译或运行时错误。
frxDBSet.TfrxDBDataset。

我看不到错误信息是如何正确的,文档也可以正确。



如果设置不正确,则警告似乎表明编译,链接和运行时错误。想知道真正发生什么的好奇心,想知道:这是什么,为什么会被添加到XE2的数据模块中。我预计其他人会绊倒这个奇怪的功能,感觉他们已经进入恐龙粪便,想知道这个功能是什么。



我现在最好的答案是数据模块对TPersistent的亲和力,这意味着在XE2语言中,该数据模块不需要非视觉控件,这是VCL特定的。在未来版本的Delphi中,也许类似的标记可以让我们将表单标记为清理VCL或Windows的依赖关系?



更新1:您的数据模块的.PAS源代码以一种看起来像编译器指令的方式存储此伪属性,如下所示:

  implementation 

{%CLASSGROUP'Vcl.Controls.TControl'}


解决方案

我认为这是很明显的,它的用途是什么,你链接的文档对于这个目的来说是非常有意义的。它旨在防止将VCL仅组件放置在FireMonkey可访问的DataModule上,反之亦然。由于TDataModule最初是框架中立的,所以只能放置框架中性的组件。显然,您的源DataModule与您的新DataModule具有不同的亲和力,这就是为什么在更改新DataModule的关联性以匹配源DataModule的亲和度之前,复制/粘贴不起作用。


I tried to copy and paste a component from one data module into another in Delphi XE2. The component was a Fast Report data source link component. The data module was brand new, just created that second, in XE2.

Someone else had the same problem and reported it on quality central as 106369 and same error message leading me to this mysterious DocWiki entry.

So data modules now have a framework affinity, and a designtime-only pseudo property, which according to the docs:

"Because the ClassGroup pseudo-property is used only by the IDE and is not a compiler-generated property (hence, 'pseudo-property'), ClassGroup is not documented in the compiler-generated Libraries Reference. The page you are reading is the documentation for ClassGroup."

So, the first time I even learn this exists is when it blocks me from copy and pasting components into my data module from an existing set of designtime building blocks that I didn't wish to rebuild from scratch.

Once I change the data module affinity, I can paste stuff into data modules without it bugging me. Thank goodness for Google-that-error or I'd be stuck.

If it is intended to help us write cross platform data modules, and yet it only affects the IDE, according to the documentation, that's inconsistent with the warning that you get when you play with this at designtime, here's the error you get if you change it:

 EInvalidType : The following component(s) are not available in the specified 
 class group. This is likely to cause compile or runtime errors. 
 frxDBSet.TfrxDBDataset.

What I can't see is how that error message can be correct, and the documentation can also be correct.

The warnings seem to suggest compile, link, and runtime errors if this is set incorrectly. Curious minds who want to know what's really going on, want to know: What is this thing about and why did it get added to the data modules in XE2. I anticipate other people will stumble upon this weird feature, with the feeling that they've stepped in something like dinosaur droppings, and want to know what is up with this feature.

My best answer at this point is that a data module affinity for TPersistent which means, in XE2 lingo, that this data module doesn't want non-visual controls in it, that are VCL-specific. In a future version of Delphi, perhaps a similar marker would allow us to mark forms as being "clean of dependencies on the VCL or windows" too?

Update 1: The .PAS source code of your data module stores this pseudo-property in a way that looks a bit like a compiler directive, like this:

implementation

{%CLASSGROUP 'Vcl.Controls.TControl'}

解决方案

I think it is pretty obviously what its intended use is for, and the documentation you link to is pretty entensive about that purpose. It is meant to prevent VCL-only components from being placed on a FireMonkey-accessible DataModule, and vice versa. Since TDataModule is initially framework-neutral, only framework-neutral components can be placed on it. So obviously, your source DataModule has a different affinity than your new DataModule, which is why copy/paste does not work until you change the affinity of the new DataModule to match the affinity of the source DataModule.

这篇关于Delphi XE2中的TDataModule.ClassGroup伪属性是做什么的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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