clipboard acClipboard component
Hierarchy Properties Methods Events
Return to Introduction  Previous page  Next page
The acClipboard component monitors the clipboard for changes and triggers special event when the content of the clipboard changes. Also it provides with super easy way to retrieve and put to clipboard the Bitmap images, plain or unicode text and list of files (the bitmap, plain text or file list are usual properties, so the clipboard content can be modified even at design-time!). In case if you are working with some more complicated or custom clipboard formats, you can use several special methods which can help you to access the clipboard just like you working with usual strings or streams.  

How to use?
To monitor the clipboard for changes — drop the component to your form and write OnChange event handler (Active property should be True for monitoring).  
The component provides easy access to the bitmap image, plain text and list of files in the clipboard. You can work with bitmap, text and file list just as usual properties. To retrieve or put these values to clipboard — use ClipboardBitmap, ClipboardText and ClipboardFiles properties.  
To check which formats currently are available in the clipboard — you can use out AvailableFormats property or check whether necessary format available using HasFormat function.  
To retrieve the raw data from clipboard as string or stream — use GetString or GetStream methods. To put the data to clipboard — use PutString or PutStream. To erase all the content of clipboard — call Clear method.  

// Demonstrates how to be notified when the content of the clipboard changes  
// and refresh the "Paste" menu items when some format appears or disappears from the clipboard.  
procedure TacFormHelpEditor.acClipboard1Change(Sender: TObject);  
  PasteTextItem.Enabled := acClipboard1.HasFormat(CF_TEXT);  
  // here is an alternative  
  PasteBitmapItem := acClipboard1.HasFormat('BITMAP'); // <-- you can specify format name as string