Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to save and restore font properties in the registry (3) Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
28-Sep-02
Category
Win API
Language
Delphi 2.x
Views
79
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: William Gerbert 

What is the best way to store the font for a TDBGrid. I can change it fine with a 
Font Dialog but how can i store those settings so they take effect the next time 
the user fires up the program ?

Answer:

Save a font:


1   function SaveFont(F_Font: TFont): boolean;
2   var
3     FLog: TLogFont;
4     Reggy: TRegistry;
5   begin
6     GetObject(F_Font.Handle, SizeOf(FLog), @FLog);
7     Reggy := TRegistry.Create;
8     try
9       Reggy.OpenKey({'\REGKEYNAME'}, true);
10      Reggy.WriteBinaryData({'VALUENAME'}, FLog, SizeOf(FLog));
11      result := true;
12    finally
13      Reggy.Free;
14    end;
15  end;
16  
17  
18  //Get a font:
19  
20  
21  function SetFont(F_Font: TFont): boolean;
22  var
23    FLog: TLogFont;
24    Reggy: TRegistry;
25    NewFHnd: longint;
26  begin
27    result := false;
28    Reggy := TRegistry.Create;
29    try
30      if Reggy.OpenKey({'\REGKEYNAME'}, false) and
31        Reggy.ValueExists({'VALUENAME'}) then
32      begin
33        Reggy.ReadBinaryData({'VALUENAME'}, FLog, SizeOf(FLog));
34        {set Font to the retrieved font}
35        NewFHnd := CreateFontIndirect(FLog);
36        result := (NewFHnd <> 0);
37        if result then
38          F_Font.Handle := NewFHnd;
39      end;
40    finally
41      Reggy.Free;
42    end;
43  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC