views:

769

answers:

2

I'm trying to write a class in Delphi 2007 that uses a ActiveX library. The class will catch an event that the ActiveX library has to expose its own event that adds some information to the ActiveX library's event.

The bottom line is that when I assign my own procedure to the ActiveX library's event that I want to use, I get an error:

E2009 Incompatible types: 'Parameter lists differ'

I'm certain the parameter lists are the same (same number of parameters and same types) so I'm thinking I'm going about it the wrong way.

Any suggestions or can someone post some sample code of what I'm trying to do?

+3  A: 

The first thing to check is that the thing you're trying to assign to the event property is a method. It needs to be a procedure or function that belongs to a class; it can't be a standalone subroutine.

Next, note that merely confirming that the names of the types match isn't enough. Delphi allows redefining an identifier, so the type name you see in one unit isn't necessarily referring to the same thing when you see the same identifier in another unit. The meaning can even change in the middle of a unit. For example:

unit Example;

interface

uses Windows;

var
  foo: TBitmap;

implementation

uses Graphics;

var
  bar: TBitmap;

end.

The foo variable has type Windows.TBitmap, a record type, whereas bar has type Graphics.TBitmap, a class type.

You can let the IDE help you diagnose this: Ctrl+click on the identifier names and let the IDE take you to their declarations. Do they take you to the same places? If not, then you can qualify the type names with the unit names. For example, we could change the bar declaration above to this:

var
  bar: Windows.TBitmap;

Now it will have the same type as foo. Check for the same sort of thing in your event-handler declaration.

Rob Kennedy
A: 

I used gabr's advice with the Ctrl+click and discovered that one of the parameters was a constant which I did not realize. I changed the second variable to a const and it worked fine. Thanks.

Dave