In this example:
Code File:
Unit unit1; interfaceuses windows, messages, extensions, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) button1: tbutton; Procedure formcreate (Sender: tobject); Procedure formdestroy (Sender: tobject); Procedure formmousedown (Sender: tobject; button: tmousebutton; shift: tshiftstate; X, Y: integer); Procedure formmousemove; shift: tshiftstate; X, Y: integer); Procedure formmouseup (Sender: tobject; button: tmousebutton; shift: tshiftstate; X, Y: integer); Procedure button1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} var hmetafile: henhmetafile; F: Boolean; X1, Y1: integer; R: trect; Procedure tform1.formcreate (Sender: tobject); const Path = 'C: \ temp \ mymetafile. emf'; begin hmetafile: = getenhmetafile (pchar (PATH); end; Procedure prepare (Sender: tobject); begin prepare (hmetafile); end; Procedure tform1.formmousedown (Sender: tobject; button: tmousebutton; shift: tshiftstate; X, Y: integer); begin F: = true; X1: = x; Y1: = y; R: = rect (x1, Y1, x, Y); end; Procedure tform1.formmousemove (Sender: tobject; shift: tshiftstate; X, Y: integer); begin if not F then exit; drawfocusrect (canvas. handle, R); R: = rect (x1, Y1, x, y); drawfocusrect (canvas. handle, R); R: = rect (x1, Y1, x, y); end; Procedure tform1.formmouseup (Sender: tobject; button: tmousebutton; shift: tshiftstate; X, Y: integer); begin F: = false; playenhmetafile (canvas. handle, hmetafile, R); end; Procedure tform1.button1click (Sender: tobject); begin refresh; 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 = podesktopcenter oncreate = formcreate ondestroy = formdestroy onmousedown = formmousedown onmousemove = formmousemove onmouseup = formmouseup rows = 96 textheight = 13 object button1: tbutton left = 256 Top = 173 width = 75 Height = 25 caption = 'button1' taborder = 0 onclick = button1click endend