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 a TFont in a stream 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
12-Oct-02
Category
Graphic
Language
Delphi 2.x
Views
103
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How can I save a font (including all its properties like color, angle, etc.) to a 
stream?

Answer:

1   { ... }
2   type
3     FontRec = packed record
4       Color: TColor;
5       LogFont: TLogFont;
6     end;
7   
8   procedure ReadFont(s: TStream; font: TFont);
9   var
10    fRec: FontRec;
11    sz: integer;
12  begin
13    s.read(sz, SizeOf(Integer));
14    if sz = SizeOf(fRec.LogFont) then
15    begin
16      s.read(fRec, SizeOf(fRec));
17      font.Handle := CreateFontIndirect(fRec.LogFont);
18      font.Color := fRec.Color;
19    end;
20  end;
21  
22  procedure WriteFont(s: TStream; font: TFont);
23  var
24    fRec: FontRec;
25    sz: integer;
26  begin
27    sz := SizeOf(fRec.LogFont);
28    if Windows.GetObject(font.Handle, sz, @fRec.LogFont) > 0 then
29    begin
30      s.write(sz, SizeOf(Integer));
31      fRec.Color := font.Color;
32      s.write(fRec, SizeOf(fRec));
33    end
34    else
35    begin
36      sz := 0;
37      s.write(sz, SizeOf(Integer));
38    end;
39  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