Board index » delphi » creating a tbitmap in d1 doesn't work but does in d2 and d3

creating a tbitmap in d1 doesn't work but does in d2 and d3

I try a simple thing as:
     thebitmap:=tbitmap.create;

this compiles fine in d2 and d3.  in d1, the help says it should be fine
but when I try to compile it tells me that I need something like
tbitmap(??).  What is wrong?

 

Re:creating a tbitmap in d1 doesn't work but does in d2 and d3


Quote
In article <34857964.6...@civerex.com>, Dominic Fortin wrote:
> What is wrong?

The compiler doesn't lie. It is telling you exactly what is wrong, but
you aren't believing it. In D3, an identifier called 'TBitmap' is
declared in both the Graphics unit and the Windows (or WinTypes) unit.

Which identifier is used depends on the order of the units in your uses
clause -- you have Windows after Graphics, so you are using
Windows.TBitmap, which is a record, not a class.

You can either re-order your uses clause (place Graphics after
Windows), or fully qualify your reference, like this:

 thebitmap := Graphics.TBitmap.Create;

Cheers.

--
Rick Rogers (TeamB) | Fenestra Technologies

Re:creating a tbitmap in d1 doesn't work but does in d2 and d3


Quote
In article <34857964.6...@civerex.com>, Dominic Fortin wrote:
> this compiles fine in d2 and d3.  in d1, the help says it should be fine
> but when I try to compile it tells me that I need something like
> tbitmap(??).  What is wrong?

Make sure that Graphics comes after any of the windows units in your uses
clause. There are TBitmaps defined in Graphics and in WinTypes. The compiler
will choose the one that appears last in the uses clause. You can also
qualify it like:

var
  myBitmap: Graphics.TBitmap;
begin
  myBitmap := Graphics.TBitmap.Create;

Regards
Ralph (TeamB)
Herrsching, Germany, Wed, 03 Dec 1997 16:43 +0100 CET

Other Threads