Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
|
Display text diagonally
This article has not been rated yet. After reading, feel free to leave comments and rate it.
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:
 | |  | |
procedure Draw_Watermark_on_DC (const aDC : hDC; const x,y : integer);
var
plf : TLOGFONT;
hfnt, hfntPrev : HFONT;
const
txt1 : PChar = 'Created with the demo version of'#0;
txt2 : PChar = ' pasDOC'#0;
WaterMarkWidth = 300;
WaterMarkHeight= 300;
begin
ZeroMemory (@plf, sizeof(plf));
lstrcpy(plf.lfFaceName, 'Arial');
plf.lfHeight := 30;
plf.lfEscapement := 0;
plf.lfOrientation:= 450;
plf.lfWeight := FW_NORMAL;
plf.lfCharset:= ANSI_CHARSET;
plf.lfOutPrecision := OUT_TT_PRECIS;
plf.lfQuality := PROOF_QUALITY;
hfnt := CreateFontIndirect(plf);
SetBkMode(aDC, TRANSPARENT);
hfntPrev := SelectObject(aDC, hfnt);
Windows.TextOut(aDC, x, y + WaterMarkHeight - 25, txt1, strlen(txt1));
Windows.TextOut(aDC, x+plf.lfHeight * 3, y + WaterMarkHeight - 25, txt2, strlen(txt2));
SelectObject(aDC, hfntPrev);
DeleteObject(hfnt);
end;
| |  | |  |
Comments:
|