views:

216

answers:

3

I am trying to get rid of lots of warnings in a project after converting it from BDS 2006 to Delphi 2009.

The project needs a type library named MSHTML_TLB. The source file mshtml_tlb.pas is an incredibly large file (about 16MB and >440.000 lines of code) which is generated when the Type Library is imported into Delphi 2009.

This file produces many warnings when building the project:
W1010 Method 'ToString' hides virtual method of base type 'TObject'

Since Delphi itself has created that file, I am wondering why these warnings come up and if I should just ignore them? If so, is there a way to disable this kind of warning just for this file?

+3  A: 

Delphi introduced this virtual method in TObject. Your declaration of ToString in a derived class does not use override so the ToString method of TObject is not accessible anymore. Adding override to your ToString method should solve the problem unless you declared your method differently.

Joe Meyer
There are no declarations of ToString anywhere in my project code. MSHTML_TLB is only used to save a bitmap of a TWebBrowser component. Even if I take all code related to MSHTML_TLB out, just leave the uses clause, I get the same warnings.
Holgerwa
Holger, if you imported the type library, and that code declares ToString, then there *is* a ToString declaration in your code. (Just because you didn't write it yourself doesn't mean you're helpless when there's a problem with it. Try getting that past your boss.) The unit is included in your project, so it's compiled whether or not any other units use it. Warnings come on compilation, not on use. Either "override" or "reintroduce" the ToString method in the import unit to fix the warning.
Rob Kennedy
+2  A: 

Write to the beginning of the MSHTML_TLB.pas file this line (in bold):

unit MSHTML_TLB;
{$WARNINGS OFF}

and at the end:

{$WARNINGS ON}
end.
Compiler directives are reset at the start of each unit anyway. There's no need to turn them back on at the end of the unit.
Rob Kennedy
In Delphi 2007 this is, unfortunately, important (I can send an example). In Delphi 2010 is now just as you write.
A: 

As a last resort, you can hide warnings. In Delphi 2010 this is in Project Options/Delphi Compiler/Hints and Warnings. I think this particular warning is "Redeclaration of a symbol hides a member in the base class".

Alan Clark