tagBitmap @ DELPHI ???什么样的? [英] tagBitmap @ DELPHI ??? What type?

查看:542
本文介绍了tagBitmap @ DELPHI ???什么样的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一个错误:


[DCC错误] Unit_TProcessClass.pas(334):E2010不兼容类型:'TBitmap'和' tagBITMAP'

[DCC Error] Unit_TProcessClass.pas(334): E2010 Incompatible Type: 'TBitmap' and 'tagBITMAP'

该类定义为

TMyClass = Class 
private
  MyBMP : TBitmap;
  property aBMP : TBitmap read MyBMP write MyBMP;

,代码如

processABitmap(aMyClass.aBMP) ;  -> here is the compile error !!! 


推荐答案

问题是有两种类型命名为 TBitmap 在VCL中。一个在 Windows 单元中定义,一个在 Graphics 单元中定义。很明显,你正在将 Windows.TBitmap 传递给一个期望 Graphics.TBitmap 的函数,反之亦然。

The problem is that there are two types named TBitmap in the VCL. One defined in the Windows unit and one defined in Graphics unit. Clearly you are passing Windows.TBitmap to a function expecting Graphics.TBitmap, or vice versa.

你几乎肯定不想与 Windows.TBitmap 有任何关系。所以解决方案是确保您的所有单位列出图形单位 Windows 单位在uses子句中。这将具有隐藏 Windows.TBitmap 的作用。

You almost certainly don't want to have anything to do with Windows.TBitmap. So the solution is to make sure that all of your units list the Graphics unit after the Windows unit in the uses clause. This will have the effect of hiding Windows.TBitmap.

我的心理调试表明,其中 TMyClass 被声明不会列出图形在其中使用子句,或者在 Windows 之前列出 Graphics

My psychic debugging suggests that the unit in which TMyClass is declared either does not list Graphics at all in its uses clause, or it lists Graphics before Windows.

最后,你会如何去做这样的事情呢?那么,尝试按CTRL +点击 TBitmap TMyClass 中引用。我相信他们会带你到 Windows 中声明的 TBitmap 。这应该足够让你明白,当你写 TBitmap 时,这不是你所指的类型。

Finally, how would you go about working out something like this yourself? Well, try pressing CTRL+click on the TBitmap referenced in TMyClass. I'm confident that they will take you to the TBitmap declared in Windows. That should be enough for you to work out that it's not the type that you meant when you wrote TBitmap.

这篇关于tagBitmap @ DELPHI ???什么样的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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