1

I don't really understand this 'incompatible types' error (Delphi XE2)

function TWaveBase.GetHandle: THandle;
begin
  if HandleNeeded then begin
    if HandleAllocated then
      CloseHandle;
    CreateHandle(False);
  end;
  FHandleNeeded:=False;
  Result:=FHandle;
end;

[...]

property Handle:Cardinal read GetHandle; -> error here

RRUZ
  • 134,889
  • 20
  • 356
  • 483
volvox
  • 1,194
  • 6
  • 22
  • 29

1 Answers1

3

THandle is a type declared based on Cardinal in Delphi XE. (Because of 64-bit and cross-platform, it's defined as NativeUInt in XE2). It's a new type.

If your GetHandle getter is returning a THandle, your property should also be declared as a THandle. Change it and things should work fine.

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • So (related to DelphiXE2) i made the change for NativeUInt. I have now this impasse, another incompatible error types Integer and AntiveInt related with MMSystem WaveInClose. -> WaveInClose method returns system.cardinal – volvox Nov 08 '11 at 04:41
  • @volvox: This is caused by the same type of error, so the fix would be the same - change one of the types to be compatible with the other. Use the XE2 types when possible, because they'll work XPlatform and in 64-bit, as I mentioned above. (And my answer was to make the change to `THandle`, not `NativeUInt`, if you'll read it more carefully; this keeps it compatible both backwards and going forward.) – Ken White Nov 08 '11 at 12:00
  • Thanks - i finally took the project under Delphi 2007 - cause too many library not up to date to deal with. – volvox Nov 08 '11 at 14:46
  • i feel ur pain. i am converting ~ 100 Mb of sources 2006->XE2 :-) And some components like ToolBar97 and pascal HTMLViewer and dead long ago. – Arioch 'The Jul 26 '12 at 09:23