<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>Hello everyone!<br>I'm new to FPC/Lazarus, and I would like to thank everyone involved for the great work. I have maybe a stupid question: I am trying to understand how Lazarus applies FORMDATA resources to forms. Specifically, in the standard main unit situation like this:<br><br><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">------- unit1.pas -------</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">unit Unit1; </span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span
style="font-family: Courier New,courier,monaco,monospace,sans-serif;">type</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> TForm1 = class(TForm)</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> Button1: TButton;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> end;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">var</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family:
Courier New,courier,monaco,monospace,sans-serif;"> Form1: TForm1;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">------ unit1.lfm -------</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">object Form1: TForm1</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> Left = 383</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> Height = 300</span><br style="font-family: Courier
New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> Top = 175</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> Width = 400</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> Caption = 'Form1'</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> ClientHeight = 300</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> ClientWidth = 400</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier
New,courier,monaco,monospace,sans-serif;"> LCLVersion = '0.9.26.2'</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> object Button1: TButton</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> Left = 151</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> Height = 25</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> Top = 137</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier
New,courier,monaco,monospace,sans-serif;"> Width = 75</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> Caption = 'Button1'</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> TabOrder = 0</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> end</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">end </span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span
style="font-family: Courier New,courier,monaco,monospace,sans-serif;">-------</span><br><br>I consider unit.lrs to be simply a translation of unit1.lfm (right?).<br>Now, unit1.lrs seems to be applied in a way that the newly created TForm1 is assigned to Unit1.Form1, and the newly created TButton is both a child of Unit1.Form1 and assigned to Unit1.Form1.Button1 (right?)<br>I want to have a similar behavior for custom components (data keepers etc.) with or without Lazarus (I also have to do command-line tools and would like to move away from C). Like<br><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">------- myunit.pas -------</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier
New,courier,monaco,monospace,sans-serif;">type</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> TMyComponent = class(TComponent)</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> FChild : TSomeComponent;<br> procedure DoSomething;<br> end;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">var</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> MyComponent : TMyComponent;</span><br style="font-family: Courier
New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">implementation</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">procedure TMyComponent.DoSomething;<br>
begin</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> // Do something with FChild</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">end;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">------- myunit.lfm -------</span> <br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">object MyComponent: TMyComponent</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span
style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> object FChild : TSomeComponent</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> SomeProperty : 42</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;"> end</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">end</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">-------</span> <br><br>However, when I use ReadComponentFromBinaryStream() or similar methods to stream
properties and assign the new component (manually) to MyUnit.MyComponent, I get a TSomeComponend named FChild which is a child of MyComponent, but it is not assigned to MyUnit.MyComponent.FChild. If I call MyComponent.DoSomething, FChild is nil. This is not what I want.<br>Of course, I could iterate through the freshly created components after doing ReadComponentFromBinaryStream() and use RTTI for TMyComponent (and its field components) to fix references (I could do that, right?), but isn't it possible to use existing code for that? As far as I understand the RTL docs, FixupReferences() etc. have nothing to do with that (right?). So, if the code which I'm looking for exists (or the functionality is documented somewhere), where is the code/the documentation (even Delphi docs, if the implementations in Lazarus and Delphi are similar)?<br><br>Maybe related: Function pointers are always unassigned after streaming when using functions like
ReadComponentFrom...(), even if i use WriteComponentTo...() (with assigned function pointers) first and then just re-read the stream. Why is that?<br><br>I hope this describes the problem/question correctly and I haven't overlooked any existing docs/discussions.<br><br>Thanks again.<br>ML<br>
</div>
</div><br>
</body></html>