In this example:
Code File:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls, extctrls; Type tform1 = Class (tform) radiogroup1: tradiogroup; procedure formcreate (Sender: tobject); Procedure formpaint (Sender: tobject); Procedure radiogroup1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses gdipobj, gdipapi; Procedure tform1.formcreate (Sender: tobject); begin radiogroup1.caption: = 'paint brush for paint'; radiogroup1.items. commatext: = 'solid painter, shadow painter, texture painter, gradient painter '; radiogroup1.itemindex: = 0; end; Procedure tform1.formpaint (Sender: tobject); var G: tgpgraphics; P: tgppen; IMG: tgpimage; B: tgpbrush; begin G: = tgpgraphics. create (canvas. handle); IMG: = tgpimage. create ('C: \ temp \ small.jpg '); {the file must exist} case radiogroup1.itemindex of 0: B: = tgpsolidbrush. create (aclred); 1: B: = tgphatchbrush. create (hatchstylesoliddiamond, aclyellow, aclcornflowerblue); 2: B: = tgptexturebrush. create (IMG); 3: B: = tgplineargradientbrush. create (makepoint (0, 0), makepoint (clientwidth-radiogroup1.width, clientheight), aclyellow, aclred); end; P: = tgppen. create (B, 24); G. drawellipse (p, 30, 30, ClientWidth-RadioGroup1.Width-60, ClientHeight-60); G. drawline (p, 0, 0, ClientWidth-RadioGroup1.Width, clientheight); IMG. free; B. free; p. free; G. free; end; Procedure tform1.radiogroup1click (Sender: tobject); begin repaint; end.
Form file:
Object form1: tform1 left = 0 Top = 0 caption = 'form1' clientheight = 206 clientwidth = 339 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 radiogroup1: tradiogroup left = 248 Top = 0 width = 91 Height = 206 align = alright caption = 'radiogroup1' taborder = 0 onclick = radiogroup1click endend