Forum > Packages and Libraries

Dynamic Creation of TSynEdit control with default settings


I want to dynamically create a TSynEdit control with the same default settings (i.e. properties) as those created at design time. I'm thinking of doing this by transforming the portion of the .lfm file that contains these settings into code. Is there a smarter method?

Create a new TFrame and copy/paste your TSynEdit onto that. You will need to copy and rebind all your notify events.

Then create the TFrame derived class via code. Usually this means adding it to dynamically created TTabSheets parented by a TPageControl.

I'm unaware of a tool which auto creates code from a pas/lfm file, but I'm sure its possible. Usually I hand convert designtime stuff to a custom class, which is a little time consuming.

You can "plonk" a TFrame derived class directly onto a TForm in design time, but I've found that to be a nightmare.

If you have the lfm standalone (without the form data or other components in the lfm), then: TReader (and some tools in the IDE).

Otherwise, create a (binary) lfm stream from the existing SynEdit via TWriter, and then use TReader.

Something like

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure ....var  strm: TMemoryStream;  Driver: TAbstractObjectWriter;  Writer: TWriter;  Reader: TReader;begin  strm := TMemoryStream.Create;  Driver := TBinaryObjectWriter.Create(strm,4096);  Writer := TWriter.Create(Driver);  Writer.WriteRootComponent(ASourceComp);  Driver.Free;  Writer.Free;   strm.Position := 0;  Reader := TReader.Create(strm, 4096);  Reader.ReadRootComponent(ADestComp);  Reader.Free;   strm.Free;end; 


[0] Message Index

Go to full version