Learn more about GDI + [44]: text output-font

Source: Internet
Author: User
In this example:


Code File:
Unit unit1; interfaceuses windows, messages, extensions, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) listbox1: tlistbox; Procedure formpaint (Sender: tobject); Procedure formcreate (Sender: tobject); Procedure listbox1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses gdipobj, gdipapi; var fontname: String = ''; Procedure tform1.formcreate (Sender: tobject); var STR: string; begin listbox1.align: = alright; for STR in screen. fonts do if STR [1] '@ 'then listbox1.items. add (STR); end; Procedure tform1.formpaint (Sender: tobject); var G: tgpgraphics; B: tgpbrush; Font: tgpfont; fontfamily: tgpfontfamily; begin G: = tgpgraph. create (canvas. handle); B: = tgpsolidbrush. create (aclred); fontfamily: = tgpfontfamily. create (fontname); Font: = tgpfont. create (fontfamily, 48, fontstylebold); G. drawstring ('delphi ',-1, Font, makepoint (5.0, 20.0), B); text: = format ('height: % F', [font. getheight (g)]); fontfamily. free; font. free; B. free; G. free; end; Procedure tform1.listbox1click (Sender: tobject); begin fontname: = listbox1.items [listbox1.itemindex]; repaint; end.
 
   
 

Form file:

 
Object form1: tform1 left = 0 Top = 0 caption = 'form1' clientheight = 126 clientwidth = 375 color = clbtnface font. charset = default_charset font. color = clwindowtext font. height =-11 font. name = 'tahoma 'font. style = [] oldcreateorder = false position = pow.topcenter oncreate = formcreate onpaint = formpaint pixelsperinch = 96 textheight = 13 object listbox1: tlistbox left = 242 Top = 8 width = 121 Height = 97 itemheight = 13 taborder = 0 onclick = listbox1click endend

  

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.