Hello

Am running into a problem on how to store the TFont properties of a memo (or any component at that) to a database

Please help.

Search for ReadComponent/WriteComponent. These are the functions also used to store them in the .dfm. You can use them to store them in a stream or string, and write that to the database.

Forgot, TFont is not a TComponent. This link describes how you can do it nicely.

Thanks for the prompt reply @pritaeas,

To access the properties and having them in string ended up using the code below;

MyFont := EditBox.Font.Name;
MyStyle := IntToStr(Byte(EditBox.Font.Style)); 
MyColor := IntToStr(Byte(EditBox.Font.Color));
MySize := EditBox.Font.Size;

With this it was easy to save to a database and apply the reverse when reading from the database
i.e.

EditBox.Font.Name := FieldByName('MyFont').asstring;
EditBox.Font.Style := TFontStyles(Byte(FieldByName('MyStyle').asinteger));
EditBox.Font.Color := FieldByName('MyColor').AsInteger;
EditBox.Font.Size := FieldByName('MySize').asinteger;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.