Please consider this simplified example:
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;
In method drwgrd1DrawCell I’ve explicitly used Windows.TRect to resolve ambiguity beetween TRect defined in two different units. Everything works fine, code is compiling.
But everytime when I save the above unit I am getting a question from the Delphi IDE which asks: “The drwgrd1DrawCell method referenced by drwgrd1.OnDrawCell has an incompatible parameter list. Remove the reference?“
This is very annoying. Is there any way to turn off this message dialog or to write my code in a way that it would not be shown? Unfortunately I can not change my TRect for TRect2 or something like that.
The reason you are getting the error when you save the form is because Delphi compares the declaration of all event handlers to ensure they are declare exactly the same as their inherited implementations. Adding
Windows.to the declaration makes the compare fail.You can remove the
Windows.fromdrwgd1DrawCell()if you move theWindowsunit after the other unit in theusesclause that declaresTRect. This is because Delphi processes the units in theusesclause from the last to the first. It will use theTRectfrom the first instance that it finds…