[Lazarus] Dynamic Form Components - SynEdit Help Please...

Mattias Gaertner nc-gaertnma at netcologne.de
Mon Oct 3 23:46:59 CEST 2016


On Mon, 3 Oct 2016 22:17:05 +0100
Martin Collins via Lazarus <lazarus at lists.lazarus-ide.org> wrote:

>[...]

You didn't wrote, why you need RTTI.
Simply access the TSynEdit:

procedure TMainForm.SaveSynEdit(ThisPage: Integer);
var
   HTMLFile: TStringList;
   Filename: String;
   Comp : TComponent;
   PropInfo: PPropInfo;
   aSynEdit: TSynEdit;
begin
   FileSaveDialog.Title:= 'Save File...';
   FileSaveDialog.DefaultExt := 'html'; //default extension
   FileSaveDialog.Filter := 'HTML source file|*.html';
   Filename:= FileList[ThisPage];
   FileSaveDialog.FileName:= Filename + '.html';
   If FileSaveDialog.Execute then
   begin
//     HTMLFile:= TStringList.Create;
     Comp := PageControlEditor.ActivePage.Controls[0];
     If Comp is TSynEdit then
     begin
       aSynEdit:=TSynEdit(Comp);
//       If IsPublishedProp(Comp, 'Lines') then
//       begin
//         PropInfo := GetPropInfo(Comp, 'Lines', [tkClass]);
//         HTMLFile := TStringList(GetObjectProp(Comp, PropInfo,
TStrings)); Filename:= FileSaveDialog.FileName;
         aSynEdit.Lines.SaveToFile(Filename);
//         HTMLFile.Free;
         FileList[ThisPage]:= Filename;
         PageControlEditor.ActivePage.Caption:=
ExtractFileName(Filename);
         PageControlEditor.ActivePage.Font.Style:= [];
         PageControlEditor.ActivePage.Font.Color:= clDefault;
//       end;
     end;
   end;
end;


Mattias


More information about the Lazarus mailing list