Saving a Diagram to a dgr file using the SaveToFile command saves the objects and groups however the group structure includes reference to the saving application. If the file is opened with a different application using Diagram Studio, the reference in the group structure is not recognised and so ignored.
The Group structure is stored as:
Members = <
DControl = dmMyUnit.Obj1
DControl = dmMyUnit.Obj2
Where dmMyUnit is the name of the Unit in my application. If I use the simple DiagramDemo app to open the file, the objects are displayed but are not grouped. If I then group them in DiagramDemo and save the file, a new group is added with a members list:
Members = <
DControl = __DSOwner___.Obj1
DControl = __DSOwner___.Obj2
Unfortunately I can't reproduce the issue. With the attached sample project, the groups are saved correctly.
TestDiagramGroupSave.zip (6.6 KB)
If you create the objects on the same form as the Diagram resides on then yes, it works. But if the objects are created an a different form it does not.
TestDiagramGroupSave2.zip (25.8 KB)
Correct, you can't do that. Always create the diagram objects owned by the same component which owns the diagram.
Well, actually I can do it, I have been doing it for months. You are just saying I shouldn't do it if I want to save and load the diagram.
I must say it sounds like an odd limitation if the only reason is to ensure the prefix is always
__DSOwner___ - in which case, why include it at all?
It relies on Delphi streaming system, both at runtime and design-time. It's not trivial, and that's how you should use it for now.