tbitmap.create fails "Undeclared Identifier - Create"

Never mind this. Windows unit defines tbitmap = tagBITMAP and that's
the culprit. Don't see how I missed that when searching the units. Had
to move the windows unit from implementation section to first in the
Interface unit. That fixed the problem. I searched google but didn't
find any reference to this problem so I will post this in case someone
else runs into it.

using D2007 with all updates. Have used a procedure in many other
projects with no errors. However, in this unit I get an error on:

function LoadBMPfromRCData(rsName: string): tBitmap;
var
  rc:  tResourceStream;
begin
  result := tBitmap.create;
  rc := tResourcestream.create(hinstance, rsname, RT_RCDATA);
  try
    result.LoadFromStream(rc);
  finally
    rc.free;
  end;
end;

I've used this exact function in at least three other projects and it
still compiles with no errors. However, in this project I get an error
E2003 Undefined identifier "create" on the tbitmap.create line. Error
insight shows tbitmap is in the graphics unit but when I pause after
typing the period, no list of properties show up.

When I change the declaration to graphics.tbitmap and the creation line
to graphics.tbitmap.create the whole process then works properly.

I've gone through every unit in my uses clauses and only graphics
declares tbitmap. I've changed the order of the graphics unit in the
uses list and it makes no difference whether it's first or last. I have
other units in the same program that use tbitmap.create but no other
functions in my program return a bitmap. Don't see how that would make
a difference. I just shut down d2007 and restarted it to make sure it's
not some memory fluke -- no help there.

--
0
Joe
8/15/2008 4:55:19 PM
embarcadero.delphi.general 4258 articles. 0 followers. Follow

7 Replies
2772 Views

Similar Articles

[PageSpeed] 28
Get it on Google Play
Get it on Apple App Store

> {quote:title=Joe Hicks wrote:}{quote}
> Never mind this. Windows unit defines tbitmap = tagBITMAP and that's
> the culprit. Don't see how I missed that when searching the units. Had
> to move the windows unit from implementation section to first in the
> Interface unit. That fixed the problem. I searched google but didn't
> find any reference to this problem so I will post this in case someone
> else runs into it.

I knew the problem from the subject. :-)

Just an FYI: In case there's a time you can't just move the unit from implementation to interface to fix the problem, you can also just qualify which one you mean by adding the unit to the code:

Bitmap:  Graphics.TBitmap;

or

Bitmap: Windows.Bitmap;
0
Ken
8/15/2008 5:30:37 PM
> Just an FYI: In case there's a time you can't just move the unit 
 > from implementation to interface to fix the problem, you can also
 > just qualify which one you mean by adding the unit to the code:
> 
> Bitmap:  Graphics.TBitmap;
> 
> or
> 
> Bitmap: Windows.Bitmap;

.... or you can change the order of the units in the uses clause:

uses
    Graphics, Windows;

uses
    Windows, Graphics;

cheers,

Chris
0
Chris
8/15/2008 8:52:55 PM
Ken White wrote:

> > {quote:title=Joe Hicks wrote:}{quote}
> > Never mind this. Windows unit defines tbitmap = tagBITMAP and that's
> > the culprit. Don't see how I missed that when searching the units.
> > Had to move the windows unit from implementation section to first
> > in the Interface unit. That fixed the problem. I searched google
> > but didn't find any reference to this problem so I will post this
> > in case someone else runs into it.
> 
> I knew the problem from the subject. :-)
> 
> Just an FYI: In case there's a time you can't just move the unit from
> implementation to interface to fix the problem, you can also just
> qualify which one you mean by adding the unit to the code:
> 
> Bitmap:  Graphics.TBitmap;
> 
> or
> 
> Bitmap: Windows.Bitmap;

Thanks. I mentioned that in my post. The only problem with that
solution is that EVERY reference to tbitmap in the problem unit must be
qualified in that case and that's a bit of a pain.

--
0
Joe
8/15/2008 9:51:00 PM
Chris Morgan wrote:

> > Just an FYI: In case there's a time you can't just move the unit 
>  > from implementation to interface to fix the problem, you can also
>  > just qualify which one you mean by adding the unit to the code:
> > 
> > Bitmap:  Graphics.TBitmap;
> > 
> > or
> > 
> > Bitmap: Windows.Bitmap;
> 
> ... or you can change the order of the units in the uses clause:
> 
> uses
>     Graphics, Windows;
> 
> uses
>     Windows, Graphics;
> 
> cheers,
> 
> Chris

Thanks. in my case graphics was in the program's uses clause and
windows in the implementation section. I had to move it to the top and
first to fix the problem. My complaint about this is that something
that should have taken 2 minutes, cost me about an hour to resolve and
the whole time I'm telling myself, "surely I wasn't stupid enough to
name something else a tbitmap". I would never have guessed that the
windows unit would have done it. For something as pervasively used in
Delphi as a bitmap, I would think the windows unit would have
deliberately avoided duplicating the name and calling it something like
twinbitmap, maybe. Until I found this new declaration, I thought all of
the references to tbitmap I saw in the windows unit were the same
graphics tbitmap. I'm guessing this will not be the last time I'm
bitten by this issue. Hopefully, next time I'll think of this first.

--
0
Joe
8/15/2008 10:07:00 PM
Joe Hicks wrote:
> Chris Morgan wrote:
> 
>>> Just an FYI: In case there's a time you can't just move the unit 
>>  > from implementation to interface to fix the problem, you can also
>>  > just qualify which one you mean by adding the unit to the code:
>>> Bitmap:  Graphics.TBitmap;
>>>
>>> or
>>>
>>> Bitmap: Windows.Bitmap;
>> ... or you can change the order of the units in the uses clause:
>>
>> uses
>>     Graphics, Windows;
>>
>> uses
>>     Windows, Graphics;
> 
> Thanks. in my case graphics was in the program's uses clause and
> windows in the implementation section. I had to move it to the top and
> first to fix the problem.

You didn't _have_ to do that. You could have done as Ken suggested. You 
also could have created a new alias in your implementation section:

interface

uses Graphics;

implementation

uses Windows;

type
   TBitmap = Graphics.TBitmap;

After that declaration, "TBitmap" would refer to the one in Graphics, 
not Windows.

> My complaint about this is that something
> that should have taken 2 minutes, cost me about an hour to resolve and
> the whole time I'm telling myself, "surely I wasn't stupid enough to
> name something else a tbitmap". I would never have guessed that the
> windows unit would have done it.

You didn't have to guess. You could have asked the IDE what it thought 
"TBitmap" referred to. Ctrl+Click on it to be taken to the declaration.

Assume the compiler is telling the truth. If it tells you that TBitmap 
doesn't have a member named Create, then go look at the declaration of 
TBitmap and confirm for yourself.

> For something as pervasively used in
> Delphi as a bitmap, I would think the windows unit would have
> deliberately avoided duplicating the name and calling it something like
> twinbitmap, maybe.

That leads to other problems. It breaks the rule that you can translate 
a Windows type name to a Delphi type name by prefixing a T. It's already 
broken once with TCriticalSection.

The other side to your argument is that Windows is so pervasive it's 
rare that you could write the interface of a unit without needing it. I 
expect that the Windows unit is used more often than Graphics is, so 
maybe _it_ should have first dibs on the name TBitmap. Also, in any unit 
that Delphi creates for you, Windows, SysUtils, and Graphics are always 
declared for you, and that order generally provides the order people expect.

> Until I found this new declaration, I thought all of
> the references to tbitmap I saw in the windows unit were the same
> graphics tbitmap. I'm guessing this will not be the last time I'm
> bitten by this issue. Hopefully, next time I'll think of this first.


-- 
Rob
0
Rob
8/15/2008 11:26:55 PM
Rob Kennedy wrote:

> Joe Hicks wrote:
> You didn't have to do that. You could have done as Ken suggested. You 
> also could have created a new alias in your implementation section:
> 
> interface
> 
> uses Graphics;
> 
> implementation
> 
> uses Windows;
> 
> type
>    TBitmap = Graphics.TBitmap;
> 
> After that declaration, "TBitmap" would refer to the one in Graphics, 
> not Windows.

Good point. I hadn't thought about that. 
> 
> > My complaint about this is that something
> > that should have taken 2 minutes, cost me about an hour to resolve
> > and the whole time I'm telling myself, "surely I wasn't stupid
> > enough to name something else a tbitmap". I would never have
> > guessed that the windows unit would have done it.
> 
> You didn't have to guess. You could have asked the IDE what it
> thought "TBitmap" referred to. Ctrl+Click on it to be taken to the
> declaration.

When I held the mouse over the unqualified tbitmap, the IDE hint said
it was in the graphics unit.
> 
> Assume the compiler is telling the truth. If it tells you that
> TBitmap doesn't have a member named Create, then go look at the
> declaration of TBitmap and confirm for yourself.

I didn't guess. I did exactly what you suggested. I looked up tbitmap
in the graphics unit and saw that it had a create (which I knew had to
be there since I had used it many times before). I had no idea that
windows had a different tbitmap. So I went through every unit I had in
the interface and implentation section looking to see if somewhere
something was re-defining tbitmap. Windows used it so often that I
missed the line where it was declared. Then I searched google and read
about a dozen unrelated articles. Finally I made the code an
unqualified tbitmap again. When I would hover over it, Delphi said it
was declared in the graphics unit. However, when I CTRL-Clicked on it,
it took me to the windows unit. I should have tried this first as you
suggested but didn't think to try it because I thought something was
broken because when I typed the dot after the tbitmap, no options came
up -- now I see it was because the windows.tbitmap doesn't have any or
none that were relevent to the assignment I was making. BTW the
ctrl-click does not always work and I really have no idea why it fails
sometimes but it certainly does -- probably every day for me.

> 
> > For something as pervasively used in
> > Delphi as a bitmap, I would think the windows unit would have
> > deliberately avoided duplicating the name and calling it something
> > like twinbitmap, maybe.
> 

Actually I was talking about a tbitmap itself being pervasive, not one
unit or the other.

> That leads to other problems. It breaks the rule that you can
> translate a Windows type name to a Delphi type name by prefixing a T.
> It's already broken once with TCriticalSection.

I wasn't aware of that "rule" about naming windows elements in Delphi.
Sounds like a good plan.

> Also, in any
> unit that Delphi creates for you, Windows, SysUtils, and Graphics are
> always declared for you, and that order generally provides the order
> people expect.
> 

That has been my experience. In this case I added a tbitmap as a field
in my class and added a function that returned a tbitmap and this was
not a visual class so I had to add all the units manually as it was
being developed.

I was not aware of tCriticalSection being a duplicate. I know
AssignFile is in sysutils and windows. Does anybody have a list of
duplicated identifiers like this? That would be a good first place to
look when strange things begin to happen.
0
Joe
8/16/2008 12:39:57 AM
"Joe Hicks" <joedotah@att.net> wrote in message 
news:3509@forums.codegear.com...

Maybe you could add

type
  TTBitmap:  Graphics.TBitmap;

and then refer to TTBitMap in your code instead of Graphics.TBitmap?
0
Uffe
8/17/2008 1:43:11 PM
Reply:

Similar Artilces:

Delphi 2007 assert
The assertion message from Delphi 2007 is... "(!"SetThreadContext failed")" in ..\win32src\thread32.cpp at line 412 Any way I can patch this out? CodeGearâ„¢ Delphi® 2007 for Win32® Version 11.0.2902.10471 El 18/01/2014 21:48, Michael Leahy escribió: > The assertion message from Delphi 2007 is... > > "(!"SetThreadContext failed")" in ..\win32src\thread32.cpp at line 412 > > Any way I can patch this out? > > CodeGearâ„¢ Delphi® 2007 for Win32® Version 11.0.2902.10471 > An unofficial fix fo...

"expecting identifier or quoted identifier"
The following statement in a sqldatasource executes fine in the querybuilder and in Toad, but gives the above error when I try to test the query. The problem is the derived table; if I remove it, everything works fine. I need to use a derived table for some aggregation I'm doing. I haven't seen anyone on the web with the same problem, so I guess I'm doing something wrong? thanks, select * from (select * from tablea) a  I'm no expert in Oracle but one possible workaround I could see is to use a temp table to hold the results of "select * from tablea". Aft...

Precedence of "where" ("of", "is", "will")?
Nobody on #perl6 today could answer this one. Is: Str | Int where { $_ } the same as: (Str | Int) where { $_ } or: Str | (Int where { $_ }) ? Followup questions, Mr. President: What kind of operators are "where", "of", "is", and "will"? Is there a reason that S03 doesn't list them? What are their precedence(s)? -- Chip Salzenberg - a.k.a. - <chip@pobox.com> Open Source is not an excuse to write fun code then leave the actual work to others. Chip Salzenberg writes: &...

.ALLCOL("%COLUMN%", " ", ", ", ", ")
Do you know anyway for me to exclude a subset of columns returned by this function. We have two columns (rec_user and rec_datetime) which are in all of our tables, but when generating triggers I want automatically generate a script which does not include those two columns but does include all other columns in that table. Bruce I should add that I am using PD 9.0.0.580. Bruce "Bruce Lamb" <lamb.bruce@mayo.edu> wrote in message news:6HgI315nCHA.155@forums.sybase.com... > Do you know anyway for me to exclude a subset of columns returned by this > function. ...

"pending" and "transfer failed"
I have a GW6 or NW6 and one Post office. One often but not always recieves a frown symbol which a "transfer failed" status for their sent mail. The other doften but not always receives "pending" status for their sent mail (no frown - symbol looks normal) the other users aren't complaining so IF it happens at all its less often do you have any suggestions also - is there a GWCHECK for GW6 and where do I get it? Is the GWCheck in C1/GW Utilities the same thing if is it different? Thank You. Is this for internet mail? -- Michael J. ...

quotes, quotes, quotes...
I am getting this error and I know what is causing it, but I have no idea how to fix it, any help would be great. The script steps through the /var/log/messages file on a linux server and puts The entries into a mysql database. However when it gets to the 'hlt' line in the messages file it just barfs. The single quotes are freaking it out. I know about quotes but not how to use in this situation. Thanks, Paul Error: May 27 17:53:00 localhost kernel: Checking 'hlt' instruction... OK. <----- doesn't like this in the messages file DBD::mysql::st exec...

Old Emails "Transfer Failed" already "Delivered" and "Opened"
I have had this happen a couple times in the last several months, to different users in different PO's. A user will receive undeliverable email messages bounce, but they sent the email months ago and this is the first negative response. The sent items show the originals as delivered and opened. One of the entries though has "Transfer Failed" for a PO we don't have anymore it's been removed from the domain. Correct me if I'm wrong but "Transferred" means through the GWIA and "Delivered" is not. So I guess the messages were sent thro...

replace the "." with a ","
Oi.... I need to build a small programm in ASP.NET and chose to use C# for it.Now i got everything working but there's one little problem.the first textbox is a double. I need to make it so that when someone enters a "." then it gets replaced by a ","any ideas?Ghan  string blah = "4.2.2.2";blah = blah.Replace(".", ",");Ryan Ryan OlshanASPInsider | Microsoft MVP, ASP.NEThttp://ryanolshan.comHow to ask a question...

"Using" or "With"
Hi all Please can someone enlighten to me as regards the difference with the "Using" and "With" statement when accessing data - which is better, what are the limitations and/or any pointers. Many thanks. Regards DaveDavid WinchesterPlease mark as answer if this is the solution.  using gives you the ability to use the connection and it closes the connection directlly after you finish using it. and there is no need to try- cach - finaly. there is no limitation on using USING keywordMuhanad YOUNISMCSD.NETMy Blog || My Photos || LinkedIn I have a dataobject the re...

Replacing "\\" with "\"
Hi all I'm getting this value from a CheckBoxList control - a location of file, i have to remove "\\" and replace it with "\" and pass it to Query, how to do it, i tried with Replace, but coud'nt suceed. "\\\\Blaze10xp\\BLZ_SFS_07\\Sample Excel Files\\Excel Files\\report2.xls" thank's in advance - Prakash.C you tried Replace like this? string newstring = oldstring.Replace(@"\\",@"\");Plese, do not forget to click "Mark as Answer" on the post that helped you. Thanx!My blog: Scenes From A Developer Memory yes i tr...

"AUTO FAIL" and "NO MEMORY" errors
When I try to load GroupWise 7.0.1 agents on a couple of my servers, they don't load and there is serveral "AUTO FAIL" and "NO MEMORY" errors. GroupWise is the only thing that I load on the server and it as 3 gigs of memory. There is also cluster services installed. Did anybody experienced this problem? Yann Laplante wrote: > When I try to load GroupWise 7.0.1 agents on a couple of my servers, > they don't load and there is serveral "AUTO FAIL" and "NO MEMORY" > errors. GroupWise is the only thing that I load on the server an...

"To" and "From" missing
When I print emails, the words "To" and "From" are blank, even though the "To" name and "From name (addresser, addressee) do show up. This is not a problem for other users on my system. Suggestions In mailbox right click, view. On the message window, right click and choose print options. Make sure print header is checked. -- Barry Merchant NSC Volunteer SysOp *** no email unless requested please!! *** > In mailbox right click, view. On the message window, right click and > choose print options. Make sure prin...

"-" not "_"
I wrote a SQL statement in the data tab. I wrote a bunch of alaises as example ' word-type ' but when I hit the layout tab it converts the "-" to "_". So now my field name is ' word_type '. Is there any way to prevent this? CardGunner Don' use a hypen ( - ).  It isn't a valid character for column names.   See http://searchsqlserver.techtarget.com/expert/KnowledgebaseAnswer/0,289625,sid87_gci1188931,00.html   Here's an excerpt about column names: Letters as defined in the Unicode Standard 2.0 Decimal numbers from either B...

"Me" is better than "You"
Yes I know, strings are frozen. But let me talk about it, I really can't get through the idea of a PC talkin to me. I consider my PC as an extension of myself, not a dumb companion who addresses Me as You. Yes there are times when I get angry with Him while I work and get wrong calculations etc.., but it really is my fault, Me using wrong istructions and eventually wanting to find someone else to blame, but it's Me. And yes, I consider Thunderbird my mail program, reading my mail on my PC as Me. So I personally like to have Me in the header bar as a compact address ...

Using "+" or "||"
Using SQLAnywhere 5.5.04, I've gotten into the habit of using "||" in ISQL to indicate a string concatenation. I needed to paste my SQL statement into the PowerBuilder script painter for some embedded SQL, and PB didn't like the "||" very much at all. I changed it to "+" and it seems to be ok. Do these two operators indicate ~exactly~ the same thing? moin, afaik these two's are not the same! if you're using "||" and any term is NULL then in the resultstring the term will be ignored if you use "+" then the resu...