procedure TForm1.Button2Click(Sender: TObject); //reload rectangle
begin
FileStream:=TFileStream.Create('prova',fmOpenRead);
Node.Create(EvsSimpleGraph); // External: SIGSEGV !!!
Node.LoadFromStream(FileStream); // External: SIGSEGV !!!
FileStream.Free;
end;
You cant do this.
First, it is not how objects are instantiated. You have to use as "Node:=TTheClassYouWant.Create"
Second, if you dont want to stuck with only one kind of shape, you cant create a node from correct class. Because you dont know which kind of object is in stream.
I downloaded and looked EvsSimpleGraph source and I think you can use it's WriteObjects and ReadObjects methods but they are protected.
Still you can crack it like this:
type
TSimpleGraphCrack = class(TEvsSimpleGraph);
procedure TForm1.Button2Click(Sender: TObject);
var
fs : TFileStream;
begin
fs:=TFileStream.Create('prova',fmCreate);
try
if fGraph.SelectedObjects.Count>0 then
TSimpleGraphCrack(fGraph).WriteObjects(fs,fGraph.SelectedObjects);
finally
fs.Free;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
fs : TFileStream;
begin
fGraph.Clear;
fs:=TFileStream.Create('prova',fmOpenRead);
try
if fs.Size>0 then
TSimpleGraphCrack(fGraph).ReadObjects(fs);
finally
fs.Free;
end;
end;
Button2Click will save only selected objects on graph and Button3Click will load what is saved. If you want choose objects by some other way you may create and fill your own list by
myList:=TEvsGraphObjectList.Create;
myList.Add(NodeYouWantToSave);