In this example:
Code File:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, percentages, stdctrls, extctrls; Type tform1 = Class (tform) colorlistbox1: tcolorlistbox; trackbar1: ttrackbar; Procedure formcreate (Sender: tobject); Procedure alert (Sender: tobject); Procedure trackbar1change (Sender: tobject); end; vaR form1: tform1; implementation {$ R *. DFM} uses gdipobj, gdipapi; Procedure tform1.formcreate (Sender: tobject); Begin self. position: = pow.topcenter; colorlistbox1.align: = alright; trackbar1.showselrange: = false; trackbar1.pagesize: = 20; trackbar1.min: = 0; trackbar1.max: = 255; trackbar1.position: = trackbar1.max; end; procedure tform1.formpaint (Sender: tobject); var G: tgpgraphics; R: tgprect; SB: tgpsolidbrush; CLR: tgpcolor; Alpha: byte; begin G: = tgpgraphics. create (canvas. handle); G. clear (makecolor (255,255,255); R: = makerect (20, 20,200,150); CLR: = colorreftoargb (colorlistbox1.selected); Alpha: = trackbar1.position; CLR: = makecolor (alpha, getred (CLR), getgreen (CLR), getblue (CLR); SB: = tgpsolidbrush. create (CLR); G. fillrectangle (SB, R); sb. free; G. free; end; Procedure tform1.colorlistbox1click (Sender: tobject); begin repaint; end; Procedure tform1.trackbar1change (Sender: tobject); begin repaint; text: = format ('transparency: % d ', [trackbar1.position]); 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 oncreate = formcreate onpaint = formpaint pixelsperinch = 96 textheight = 13 object colorlistbox1: tcolorlistbox left = 248 Top = 0 width = 91 Height = 206 align = alright itemheight = 16 taborder = 0 onclick = colorlistbox1click end object trackbar1: ttrackbar left = 0 Top = 184 width = 249 Height = 45 taborder = 1 onchange = trackbar1change endend