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