Search the Community
Showing results for tags 'properties'.
Found 2 results
-
properties Is it possible to copy all properties from one TMemo to a dynamically created TMemo?
JohnLM posted a topic in VCL
Specs: XE7, VCL, Win7 I have a Panel with a TabControl in it and a Memo inside the first TabSheet on a Form that was all created and configured during design time. And, on the Form in another Panel, I have a [Add] button to dynamically create a new TabSheet and Memo. The main Memo is the default with all the settings that I would like the dynamically created Memos to have. But setting up all the necessary properties would be tedious and if I change something in the main Memo at design-time, I may not remember to update that to the dynamic ones. var Form1: TForm1; idx: integer=0; // index numb, for adding new tabs to the pagecontrol. procedure TForm1.btnAddClick(Sender: TObject); var TabSheet: TTabSheet; memo: TMemo; begin inc(idx); TabSheet := TTabSheet.Create(PageControl1); TabSheet.Caption := 'Untitled-'+idx.ToString; TabSheet.PageControl := PageControl1; memo := tmemo.Create(pagecontrol1); // settings section memo.Color := $0017110D; memo.Align := alClient; . . . // end of settings section memo.Parent := tabsheet; memo.Show; memo.SetFocus; end; note: I have a lot more properties than what is posted above. Is there a better way to copy all the properties of the main Memo to the dynamically created ones and how can I do this?- 14 replies
-
- delphi xe7
- copy
-
(and 1 more)
Tagged with:
-
I have a procedure that loads the properties of a class into a memo: procedure TForm1.GetProperties (p_Class: TClass); var v_Context: TRttiContext; v_Type: TRttiType; v_Property: TRttiProperty; begin v_Type := v_Context.GetType(p_Class); for v_Property in v_Type.GetProperties do Memo1.Lines.Add(v_Property.ToString); end; Sample Usage GetProperties(TFDPhysPGConnectionDefParams); I would like a procedure to get the properties by class name instead of a class. procedure TForm1.GetPropertiesByClassName (p_ClassName: String); // Changed var v_Class: TClass; // Added v_Context: TRttiContext; v_Type: TRttiType; v_Property: TRttiProperty; begin v_Class := GetClass(p_ClassName); // Access Violation Exception v_Type := v_Context.GetType(v_Class); for v_Property in v_Type.GetProperties do Memo1.Lines.Add(v_Property.ToString); end; Sample Usage: v_FDConnection := TFDConnection.Create(nil); try v_FDConnection.DriverName := 'PG'; GetPropertiesByClassName(v_FDConnection.Params.ClassName); finally v_FDConnection.Free; end; My attempt as shown above results in a runtime exception for Access Violation. How can I get this to work?