The method of table 7.3 Tclipboard
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Method parameter Meaning
─────────────────────────────────────
Clear the contents of the Clipboard are not cleared
Assign source:tpersistent copies the object specified by the Source parameter to the Clipboard, often
For graphics, image objects
Open the Clipboard without opening it, preventing other applications from changing its contents
Close without closing the open clipboard
SetComponent source:tpersistent Copy the parts to the Clipboard
Getcomponent Owner retrieves a part from the Clipboard and places
Parent:tpersistent
Setashandle Format:word give the handle of the specified format data to the Clipboard
return type: Thandle
Getashandle Format:word Returns a handle to the Clipboard-specified format data
return type: Thandle
Hasformat Format:word determine if the Clipboard has a given format
return type: Boolean
Settextbuf Buffer:pchar Set the Clipboard text content
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
The possible data formats in the Clipboard are the following table.
Table 7.4 Clipboard data format and its significance
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Data format meaning
──────────────────────────────
Cf_text text. Each line ends with CF_LF, nil flag text ends
Cf_bitmap Windows Bitmap
Cf_metafile Windows Meta File
Cf_picture tpicture type of Object
Cf_object any tpersistent type of object
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Use Tclipboard to implement text transfer using Astext properties and Settextbuf methods.
The Astext property provides convenience for clipboard operations for non-control parts. Such as:
Clipboard. Astext: = form1.caption;
Copy the Form1 title to the Clipboard.
Label1.Caption: = Clipboard.astext;
Writes the text from the Clipboard to the Label1.
Settextbuf is used to handcuff a string of more than 255 characters to the Clipboard.
7.1.3 Use the Clipboard to transfer images
7.1.3.1 Copy
The content on the image part and the graphics on the form can be copied directly to the Clipboard. The image copy utilizes the Clipboard assign method.
For example:
Clipboard.assign (image1.picture);
Copy the image on the Image1 to the Clipboard.
7.1.3.2 Shearing
Image cutting is the first copy of the image to the Clipboard, and then in the original location with a blank image to cover.
The following procedure represents the clipping of an image.
Procedure Tform1.cut1click (Sender:tobject);
Var
Arect:trect;
Begin
Clipboard.assign (image1.picture);
With Image.canvas do
Begin
Copymode: = cmwhiteness;
Arect: = Rect (0, 0, image.width, image.height);
Copyrect (Arect, Image.canvas, Arect);
Copymode: = cmsrccopy;
End
End