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 paint formatted text on the title bar of a TForm 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-Oct-02
Category
VCL-Forms
Language
Delphi 2.x
Views
128
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How to paint formatted text on the title bar of a TForm

Answer:

This source code allows you to write text everywhere on the form and also on the 
title bar. You can even rotate the text at a certain angle. Just keep in mind, that 
the code below only works with Truetype fonts.

1   { ... }
2   private
3   {Private declarations}
4   
5   procedure Check(var aMsg: TMessage); message WM_ACTIVATE;
6   public
7     {Public declarations}
8   end;
9   
10  var
11    Form1: TForm1;
12  
13  implementation
14  
15  {$R *.DFM}
16  
17  procedure MyTextOut(form: TForm; txt: string; x, y, angle, fontsize: Integer;
18    fontcolor: TColor;
19    fontname: PChar; italic, underline: Boolean);
20  var
21    H: HDC;
22    l, myfont: Integer;
23  begin
24    l := length(txt);
25    H := GetWindowDC(Form.handle);
26    SetTextColor(H, fontcolor);
27    SetBkMode(H, Transparent);
28    Myfont := CreateFont(fontsize, 0, angle * 10, 0, FW_SEMIBOLD, ord(italic),
29      ord(underline), 0,
30      DEFAULT_CHARSET, OUT_TT_PRECIS, $10, 2, 4, fontname);
31    SelectObject(H, myfont);
32    TextOut(H, x, y, pchar(txt), l);
33    DeleteObject(myfont);
34    ReleaseDC(Form.handle, H);
35  end;
36  
37  {Paint text on title bar}
38  
39  procedure TForm1.FormCreate(Sender: TObject);
40  begin
41    Form1.Caption := '';
42  end;
43  
44  procedure DrawText;
45  begin
46    MyTextout(Form1, 'This is italic', 30, 25, 0, 15, clYellow, 'Arial', true, false);
47    MyTextout(Form1, 'This is underline', 125, 5, 0, 15, clYellow, 'Arial', false,
48      true);
49  end;
50  
51  procedure TForm1.Check(var aMsg: TMessage);
52  begin
53    DrawText;
54  end;
55  
56  procedure TForm1.FormPaint(Sender: TObject);
57  begin
58    DrawText;
59  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