Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tagBitmap @ DELPHI ??? What type?

Tags:

delphi

I get an error :

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

the class is defined as

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

and the code goes like

processABitmap(aMyClass.aBMP) ;  -> here is the compile error !!! 
like image 376
Franz Avatar asked Nov 29 '22 02:11

Franz


1 Answers

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.

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.

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.

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.

like image 85
David Heffernan Avatar answered Jan 03 '23 23:01

David Heffernan