Is there a workaround for reporting incompatible parameters from the Delphi IDE?

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 the drwgrd1DrawCell method drwgrd1DrawCell I explicitly used Windows.TRect to resolve the beetween TRect ambiguity defined in two different units. Everything works fine, the code compiles. But every time I save the above item, I ask a question from the Delphi IDE, which asks: "The drwgrd1DrawCell method referenced by drwgrd1.OnDrawCell has an incompatible list of parameters. Delete the link?"

This is very annoying. Is there a way to disable this message dialog box or write my code so that it does not appear? Unfortunately, I cannot change my TRect to TRect2 or anything like that.

+4
source share
2 answers

The reason you get an error while saving the form is because Delphi compares the declaration of all event handlers to make sure that they are declared exactly the same as their inherited implementations. Adding Windows. to ad makes comparison fail.

You can remove Windows. from drwgd1DrawCell() if you move the Windows block after another device in the uses that declares TRect . This is because Delphi processes units in the uses from last to first. He will use TRect from the first instance he finds ...

+3
source

You can add the following type declaration above the form declaration:

  type TRect = Windows.TRect; 
+4
source

Source: https://habr.com/ru/post/1436639/


All Articles