Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

TFont to String/Other SAVABLE data.

Posted on 2000-05-01
11
Medium Priority
?
371 Views
Last Modified: 2010-05-18
In my application, I wish to allow the user to pick different font settings for things, and I want to save them in an ini file. The problem is, I have no idea how do get a TFont into a string. I'm not looking for just the font name, I want the style, name and size altogether. THis needs to be put in a string for saving/loading, so I can apply it to components and such.

Regards,
Psylord
0
Comment
Question by:Psylord
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 3
11 Comments
 
LVL 1

Accepted Solution

by:
rowisoft earned 480 total points
ID: 2765363
Hy!

Do this:
String := TFont.Name;

that's a string!!


bye
Robert
0
 
LVL 2

Expert Comment

by:mullet_attack
ID: 2765417
Try this

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TMyFontData = packed record
  Name : string[50];
  Size : integer;
  Style : TFontStyles;
end;

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
MyFontData, MoreFontData : TMyFontData;
s : string;
begin
  with MyFontData Do
    begin
      Name := 'Some Font';
      Size := 8;
      Style := [fsBold];
    end;
  SetLength(s, Sizeof(TMyFontData));
  // put the data in a string
  CopyMemory(PChar(s),@MyFontData,Sizeof(TMyFontData));

  // read the string back into a record
  CopyMemory(@MoreFontData,PChar(s),Sizeof(TMyFontData));

end;

end.
0
 

Author Comment

by:Psylord
ID: 2766937
rowisoft,
As I stated... I'm not after the font name alone. Re-read my question. :)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Psylord
ID: 2766971
mullet_attack,
What uses clause is this missing?
0
 

Author Comment

by:Psylord
ID: 2766973
Nevermind... Overlooked somthing. :)
Checking the code. :)~
0
 

Author Comment

by:Psylord
ID: 2772414
Adjusted points from 50 to 120
0
 

Author Comment

by:Psylord
ID: 2772415
mullet,

Can you do me one more thing on this?

Convert this so it writes/reads the info from an ini file and then applies it to a component...


THen the points are yours.
0
 
LVL 2

Expert Comment

by:mullet_attack
ID: 2772596
In the true spirit of re-usable code, I hate writing stuff that others have already written (I am lazy...)

have a look at this :
http://www.delphizine.com/features/1997/10/di199710rv_f/di199710rv_f.asp

it's a component that you can select properties from your objects on your form and save the values to the registry.

That brings me to another question. Why are you using ini files? For 95/98/NT development, it's usual to store stuff in the registry. I personally don't _like_ to do this, but I do 'cos everyones else does, and people expect to be able to find stuff in the registry. If you haven't used the registry before, it's almost exactly the same as using ini files. Delphi makes it _real_ easy.

If you must use ini files, then the component in the article mentioned above could easily be modified to write to a file instead of the registry.
0
 

Author Comment

by:Psylord
ID: 2772612
Not what I was looking for really but I can make it work.

Thanks for the effort though. I have more important questions to worry about though. ;)
0
 
LVL 2

Expert Comment

by:mullet_attack
ID: 2772799
why did you give the points to Rowisoft?
0
 

Author Comment

by:Psylord
ID: 2775037
ARGH!

That sucked. I'll pay yeh back.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question