Re-learning gdi+[38]: Text output

Source: Internet
Author: User

This example effect chart:

Code files:Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls;
Type
TForm1 = Class (Tform)
Button1:tbutton;
Button2:tbutton;
Procedure Button1Click (Sender:tobject);
Procedure Button2click (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Gdipobj, GDIPAPI;
Procedure Tform1.button1click (Sender:tobject);
Var
G:tgpgraphics;
Sb:tgpsolidbrush;
Font:tgpfont;
Begin
G: = Tgpgraphics.create (Canvas.handle);
SB: = Tgpsolidbrush.create (Aclblack);
{Specify font name and font size to create Tgpfont class}
Font: = Tgpfont.create (' song Body ', 9);
g.DrawString (' Feminine character pingyang flower leaning on peach edge fold flowers do not see my tears streaming streams ',-1, Font, Makepoint (10.0,20), SB);
{Parameter 2 is-1 indicates that all specified characters are output; parameter 4 must be a TGPPOINTF structure}
Font. Free;
Sb. Free;
G.free;
End
Procedure Tform1.button2click (Sender:tobject);
Var
G:tgpgraphics;
Sb:tgpsolidbrush;
Font:tgpfont;
Begin
G: = Tgpgraphics.create (Canvas.handle);
SB: = Tgpsolidbrush.create (Aclblack);
{Using the features of other DCs to establish tgpfont classes; it doesn't seem to inherit all features, such as Font color}
Canvas.Font.Name: = ' song body ';
Canvas.Font.Size: = 9;
Font: = Tgpfont.create (Canvas.handle);
g.DrawString (' Children's famous birds and elder sister also shoulder double line peach tree under the back Fu who pity ',-1, Font, Makepoint (10.0,40), SB);
Font. Free;
Sb. Free;
G.free;
End
End.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.