Maybe that writecomponent method only writes methods that were assigned at 
design-time? 

Dave

heromed <[EMAIL PROTECTED]> wrote:                               --- In 
advanced_delphi@yahoogroups.com, "anomander1" <[EMAIL PROTECTED]>
 wrote:
 >
 > --- In advanced_delphi@yahoogroups.com, "heromed" <stanton@> wrote:
 > >
 > > When I create a Component (on a panel) at Runtime and save it, the
 > > Event properties do NOT get saved. 
 > > 
 > > CAN ANYONE HELP ?
 > > 
 > > // CREATE BUTTON PROCEDURE
 > > procedure TForm1.CreateButtonClick(Sender: TObject);
 > > begin 
 > >    inc(n);
 > >    MyButton := TButton.Create(Panel1);
 > >    Mybutton.Parent := Panel1;
 > >    MyButton.Name := 'Button' + inttostr(n);
 > >    MyButton.Top := N * 30;
 > >    MyButton.OnMouseDown := MouseDown;
 > > end;
 > > 
 > > // MOUSEDOWN PROCEDURE
 > > procedure TForm1.MouseDown(Sender: TObject; Button: TMouseButton;
 > > Shift: TShiftState; X, Y: Integer);
 > > begin
 > >    beep;
 > > end;
 > > 
 > > //SAVE COMPONENT PROCEDURE
 > > procedure TForm1.SaveButtonClick(Sender: TObject);
 > > var FS : TFileStream;
 > >     MS : TMemoryStream;
 > > begin
 > >    MS := TMemoryStream.Create;
 > >    FS := TFileStream.Create('bob.txt',fmCreate);
 > >    MS.WriteComponent(Panel1);
 > >    MS.Position := 0;
 > >    ObjectBinaryToText(MS, FS);
 > >    FS.Free;
 > >    MS.Free;
 > > end;
 > > 
 > > Here is the resulting file:
 > > ---------------------------
 > > 
 > > object Panel1: TPanel
 > >   Left = 40
 > >   Top = 104
 > >   Width = 537
 > >   Height = 473
 > >   Caption = 'Panel1'
 > >   TabOrder = 4
 > >   object Button1: TButton
 > >     Left = 0
 > >     Top = 30
 > >     Width = 75
 > >     Height = 25
 > >     Caption = 'Button1'
 > >     TabOrder = 0
 > >   end
 > > end
 > >
 > 
 > I do not see a path to bob.txt
 > Maybe because you don't use a path before the filename, it will not be
 > saved.
 > Futhermore, you might want to write your own save routine instead of
 > using the MS method. Maybe that will work better and you have more
 > control over it.
 > 
 > Hope this helps.
 >
 Thank you for your comment.
 
 Both the Panel and the Button on it DOES get saved, only the
 (OnMouseDown) event is missing from the saved file.
 
 I don't know what you mean by the "MS Method".
 
 
     
                               

       
---------------------------------
Looking for last minute shopping deals?  Find them fast with Yahoo! Search.

Reply via email to