tags:

views:

170

answers:

2

Running a project and was getting an error saying
"Not enough actual parameters" The error is in "C:\Program Files\PBear\HTMLComponents\package\GDIPL2A.pas". The mistake pointed three times to "inherited Create;" lines 260,270 and 278 . In the file "GDIPL2A.pas".the Code is:-

var
  err: integer;
begin
inherited Create;
err := GdipCreateBitmapFromScan0(W, H, 0, PixelFormat32bppARGB, nil, fHandle);
if err <> 0 then
  raise EGDIPlus.Create('Can''t create bitmap');
end;

I was wondering why it would show an error in "THTML" files, WHICH ARE NOTHING BUT FILES FROM THE INSTALLATION of THTML.I did not even touch THTML files.

Kindly help

Thanks and Regards

Vas

+1  A: 

A "Not enough actual parameters" error on "inherited Create;" means that you're trying to call an inherited constructor but it not supplying any parameters. Check the class you're inheriting from and you'll see a Create that requires some parameters. (If the base class doesn't have one, check its parent, and its parent and so on. You'll find one eventually.) It should be pretty obvious once you find the constructor declaration what you need to pass to it.

Your call needs to look something like:

inherited Create(param1, param2);
Mason Wheeler
Hi! Mason I will do what you have suggested.But I was wondering that THTML being an highly tested and used application ,how could the error point to THTML/GDIPL2A.pas ?is that because there is an error in the project files or mapping or something else?
vas
No idea...
Mason Wheeler
@Mason: Actually, it doesn't. If you have a constructor that accepts parameters, and the ancestor's constructor accepts the same parameters (and types for those parameters), it's perfectly acceptable to just use inherited; - the compiler passes the parameters upward automatically. Try it yourself - a quick test should be about 15 or so lines of code.
Ken White
Ken: If it says "inherited;" then yes. But if it says "inherited Create;", as the example above, that's a very different matter.
Mason Wheeler
+1  A: 

I have THTML, and it indeed includes GDIPL2A.pas, which is a wrapper around GDIPlus; apparently THTML uses GDIPlus to display embedded images or something.

A quick look at the declaration of TGPImage and TGpBitmap shows the constructor declarations of each:


// TGpImage
public
  constructor Create(FileName: string; TmpFile: boolean = False); overload;
  constructor Create(IStr: IStream); overload;

// TGpBitmap
public
  constructor Create(W, H: Integer); overload;
  constructor Create(IStr: IStream); overload;

You'll see that all of the constructors takes at least one or two parameters; your call to inherited Create passes none. However, since the call to inherited is in another constructor it should work (and indeed does on my machine; I just tried rebuilding one of the demos from THTML and it recompiled GDIPL2A.pas fine), You've got something else going on, like a different version of GDIPL2A in your path that the compiler is using instead of the one you're seeing in the IDE's editor.

As to your question, I answered it in the first paragraph above. It's reporting the error in THTML because that's the copy of GDIPL2A that the compiler is using, which may not be the one your code is expecting it to use.

You can fix that by either:

  1. Reordering units in the uses clause of your code so that all calls that cause GDIPL2A to compile are using the same one;

  2. Copy the GDIPL2A your code thinks it's using into your project's source folder, so it will be compiled from there. This will probably break THTML if you're using it in that same project, so be ready for that;

  3. Find and resolve the competing copies of GDIPL2A so that there's only one copy available on the compiler's search path;

  4. Remove the THTML path from your project's search and library paths, if you're not using it in your problem project. You can also, using Project|Options|Packages, prevent THTML from even being loaded when you open the project if you'd like, to make your project load faster.

Ken White
1) the (THTML)fileS that are using GDIPL2A are MetaFilePrinter.pas, htmlview.pas, HTMLUn2.pas,HTMLSubs.pasHow 2 c "calls that cause GDIPL2A to compile are using the same one"? For it is simply placing the name "GDIPL2A " in the " call ".2)Sved GDIPL2A.pas in the project folder and compiled it.Still getting the same error.3) I had 2 more THTML folders in the C drive.So I removed them lest they are affecting the mapping/code.Still the same error.4)I checked "Project|Options|Packages" ..."THTML" was not added to it at all.Should I add it
vas
Hello KenIn the Delphi4 IDE /Tools/Environmental/Library the following is the mapping in descending order:-1 C:\Program Files\PBear\HTML Components\THTML\Package2 $(DELPHI)\Lib3 $(DELPHI)\Bin4 $(DELPHI)\Importsi was wondering if "Lib,bin,imports" are needed.If not can they be removed?
vas
They can be removed if they're not needed, but they shouldn't be the problem. Something is finding more than one copy of GDIPL2A, and the copies aren't the same. See my step 3 above - use Windows Explorer and do a search for GDIPL2A.*. Get rid of all matching files except the ones in the THTML folder (rename them to something totally different, for example, like Different_GDIPL2A.pas). Then try and compile your project.
Ken White
Did the above ken ,but was getting the same error
vas
vas, you're either not checking thoroughly or you have something **really** screwed up. I'm not sure what else to tell you; in the few (very rare) occasions I've had the same problem or known someone else to, the steps above have always found and repaired the problems.
Ken White