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 text diagonally 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
Display text diagonally 05-Sep-02
Category
System
Language
Delphi All Versions
Views
67
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: William Gerbert 

Display text diagonally

Answer:

To display text diagonally (or by any other degree), you need to create a font. The 
font may be created using the function CreateFontIndirect. The parameter's record 
member .lfOrientation specifies the angle in 0.1 degrees, e.g. 450 equals 45 
degrees.

When the font handle is no longer needed, it should be deleted with DeleteObject().

The following function writes a sort of watermark on a DC and uses the API function 
TextOut for this:

1   
2   procedure Draw_Watermark_on_DC(const aDC: hDC; const x, y: integer);
3   var
4     plf: TLOGFONT;
5     hfnt, hfntPrev: HFONT;
6   const
7     txt1: PChar = 'Created with the demo version of'#0;
8     txt2: PChar = '      pasDOC'#0;
9     WaterMarkWidth = 300;
10    WaterMarkHeight = 300;
11  begin
12    // Specify a font typeface name and weight.
13    ZeroMemory(@plf, sizeof(plf));
14    lstrcpy(plf.lfFaceName, 'Arial');
15    plf.lfHeight := 30;
16    plf.lfEscapement := 0;
17    plf.lfOrientation := 450;
18    plf.lfWeight := FW_NORMAL;
19    plf.lfCharset := ANSI_CHARSET;
20    plf.lfOutPrecision := OUT_TT_PRECIS;
21    plf.lfQuality := PROOF_QUALITY;
22    hfnt := CreateFontIndirect(plf);
23  
24    // Draw the rotated string
25    SetBkMode(aDC, TRANSPARENT);
26    hfntPrev := SelectObject(aDC, hfnt);
27    Windows.TextOut(aDC, x, y + WaterMarkHeight - 25, txt1, strlen(txt1));
28    Windows.TextOut(aDC, x + plf.lfHeight * 3, y + WaterMarkHeight - 25, txt2,
29      strlen(txt2));
30    SelectObject(aDC, hfntPrev);
31    DeleteObject(hfnt);
32  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