Answer the question
In order to leave comments, you need to log in
How to clear a window from elements of TImage Delphi?
The program draws a graph whose vertices are represented as records containing the image of a circle and the value of the vertex. All entries are stored in a dynamic array. When a new graph is specified, the outline of the entire form is filled in, and an array of images is removed.
Everything is cleared as required, but if the location of the top of the new graph coincides with the location of the top of the old one, then it turns out that part of the old image is superimposed on the new one. How to efficiently clear a form after deleting an array of vertices?
By the way, lines are drawn through MoveTo, LineTo and are removed without a trace after the form is filled.
Looked for a few tips, tried some - do not help.
C = record
graphical: TImage;
value: Integer;
...
Nodes: array of C;
Node: TImage;
...
procedure Cleaner; // Очистка формы от рисунков
var
r: trect;
begin
r.Height := WGraph.Height;
r.Width := WGraph.Width;
r.Top := 0;
r.Left := 0;
WGraph.Canvas.FillRect(r);
end;
...
Node.graphical.AutoSize := true;
Node.graphical.Picture.loadfromfile('white.bmp'); //Загрузка изображения
Node.graphical.Transparent := true; //Прозрачность
Node.graphical.Canvas.TextOut(14, 11, IntToStr(i + 1)); //Добавление текста
...
if NodesExists = 1 then //Проверка на существование массива с вершинами
begin
for i := 0 to length(Nodes) - 1 do
Nodes[i].graphical.Destroy;
setlength(Nodes, 0);
end;
WGraph.Refresh;
WGraph.Repaint;
Answer the question
In order to leave comments, you need to log in
If your canvas is flooded, where does the "old" image come from? Magic doesn't exist. Maybe you forget to clear the array with the old values of the vertices and they are drawn again?
Try using TPaintBox and draw on its canvas.
When drawing a new graph, in extreme cases, you can recreate the TPaintBox component.
Fill the entire space with white (or whatever you have) color. Works 100%.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question