Exception when creating and removing tools via code
Posted: Wed Jan 12, 2005 8:40 am
When creating tools (annotation tools) dynamicaly at runtime, an exception is generated when the tools are removed and then free'd.
Sample code below:
If the statement to free the tool is removed, the exception does not occur BUT all the annotations are not drawn (which is correct) except for one annotation that remains on the chart...
Help needed!!!!!
See the following post to under stand the context - the same code worked before moving the code to the OnBeforeDraw event
Sample code below:
Code: Select all
procedure TViewAnalyzer.HideZoneOverlay;
var
i : integer;
begin
for i := 0 to 19 do //max of 20 zones and annotations
begin
if (FSessionZoneBands[i] <> nil) then
begin
DBChartSession.Tools.Remove(FSessionZoneBands[i]);
FSessionZoneBands[i].Free;
FSessionZoneBands[i] := nil;
end;
if (FSessionZoneNames[i] <> nil) then
begin
DBChartSession.Tools.Remove(FSessionZoneNames[i]);
FSessionZoneNames[i].Free; //! causes an exception
FSessionZoneNames[i] := nil;
end;
end;
end;
Help needed!!!!!
See the following post to under stand the context - the same code worked before moving the code to the OnBeforeDraw event