Answer the question
In order to leave comments, you need to log in
How to pass to Unit1 an object that is in Unit3, avoiding the error: Circular unit reference to 'Unit3′?
Good afternoon, comrades. The following question appeared:
There is a TCell class, which, for convenience, is placed in a separate Unit
Type
TCell = class
Public
X1, Y1: Integer; // Координата первой точки
X2, Y2: Integer; // Координата второй точки
Width_cell: Integer; // Ширина клетки
Status: Integer; // Статус клеточки
// Пользовательский конструктор
Constructor CreateUserCell(my_X1, my_Y1, my_X2, my_Y2: Integer);
Procedure SetColorRed(); // Установить красный цвет
End;
procedure TCell.SetColorRed;
begin
Form3.Image1.Canvas.Brush.Color := clRed;
end;
Answer the question
In order to leave comments, you need to log in
Because you need to abstract in writing code. Rewrite your function like this:
procedure TCell.SetColorRed(ACanvas: TCanvas);
begin
ACanvas.Brush.Color := clRed;
end;
I don't remember Delphi well, try to move conflicting uses from interface to implementation in one of the modules. Just by the way, in this module, pieces of code of which you have given.
How to treat Circular unit reference has already been written to you, but, in my opinion, "something in the conservatory needs to be changed" here. There should not be any references to some "left" (not related to this class) forms, etc. in the class methods. Such a method should not be in your class, but in the form - Form3.SetColorRed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question