繁体   English   中英

Delphi IDE中是否存在“不兼容的参数列表”消息的解决方法?

[英]Is there a workaround for “incompatible parameter list” message from Delphi IDE?

请考虑这个简化的例子:

type
  TForm43 = class(TForm)
    drwgrd1: TDrawGrid;
    procedure drwgrd1DrawCell(Sender: TObject; ACol, ARow: Integer; 
      Rect: Windows.TRect; State: TGridDrawState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

procedure TForm43.drwgrd1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: Windows.TRect; State: TGridDrawState);
begin
  Rect.Left := 5;
end;

在方法drwgrd1DrawCell我明确地使用了Windows.TRect来解决在两个不同单元中定义的TRect歧义。 一切正常,代码正在编译。 但是每当我保存上面的单元时,我都会从Delphi IDE中得到一个问题:“ drwgrd1.OnDrawCell引用的drwgrd1DrawCell方法有一个不兼容的参数列表。删除引用?

这非常烦人。 有没有办法关闭此消息对话框或以不会显示的方式编写我的代码? 不幸的是我不能改变TRect2 TRect或类似的东西。

您可以在表单声明上方添加以下类型声明:

    type
      TRect = Windows.TRect;

保存表单时出现错误的原因是因为Delphi比较了所有事件处理程序的声明,以确保它们的声明与它们的继承实现完全相同。 添加Windows. 声明使比较失败。

您可以删除Windows. 如果您在声明TRectuses子句中的另一个单元之后移动Windows单元,则从drwgd1DrawCell() 这是因为Delphi从最后一个到第一个处理uses子句中的单元。 它将使用它发现的第一个实例的TRect ...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM