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 Display WYSIWYG fonts in a list box 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
13-Aug-03
Category
VCL-General
Language
Delphi 2.x
Views
115
User Rating
10
# Votes
1
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jorge Abel Ayala Marentes

You can display the available fonts in a WYSIWYG fashion.

Answer:

Start a new project, add a TListBox, in the Form´s OnCreate event code: 
1   
2   procedure TForm1.FormCreate(Sender: TObject);
3   begin
4     ListBox1.Items := Screen.Fonts;
5   end;


Set the ListBox´s style property to lbOwnerDrawVariable and finally and the 
following code to the ListBox´s OnDrawItem and OnMeasureItem events 
6   
7   procedure TForm1.ListBox1MeasureItem(Control: TWinControl; Index: Integer;
8     var Height: Integer);
9   var
10    h: integer;
11  begin
12    with Control as TListBox do
13    begin
14      Canvas.Font.Name := Items[Index];
15      h := Canvas.TextHeight(Items[Index]);
16    end;
17    Height := h;
18  end;
19  
20  procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
21    Rect: TRect; State: TOwnerDrawState);
22  begin
23    with Control as TListBox do
24    begin
25      Canvas.Font.Name := Items[Index];
26      Canvas.FillRect(Rect);
27      Canvas.TextOut(Rect.Left, Rect.Top, Items[Index]);
28    end;
29  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