1. Technology

Listening to the Clipboard: Clipboard Delphi Spy with Custom Clipboard Formats

TClipboard has Limitations


Clipboard View Custom Format

Clipboard View Custom Format

One of the nice things about Windows is that it lets us cut and paste items from one application to another. It does so, behind the scenes, with the Clipboard. One of the nice things about Delphi is that it gives us quick and easy access to clipboard functions, formats, events and methods.

For some of the standard operations like Copy and Paste, Delphi provides us with the TClipboard class.

Clipboard stores information in multiple formats so we can transfer data between applications that use different formats. When reading information from the clipboard with Delphi's TClipboard class, we are limited to standard clipboard formats: text, pictures and metafiles.

Suppose we have two different Delphi applications running, what do you say about defining custom clipboard format in order to send and receive data between those two (Delphi) programs?

Suppose we are trying to code a Paste menu item - we want it to be disabled when there is no, lets say, text in the clipboard. Since the entire process with the clipboard takes place behind the scenes, there is no method of TClipboard class that will inform us that there has been some change in the contents of the clipboard. What we need is to hook in the clipboard notification system, so we can get and respond to events when the clipboard changes.

If we want more flexibility and functionality we have to reach for Win API and messaging system.

  1. »Receiving Clipboard Change Notifications
  2. »Working with Custom Clipboard Formats

©2014 About.com. All rights reserved.