Clipboard Viewer Component

   
Release: 1.4
Date: 13 October 2010
Delphi Compatibility:
 D1   D2   D3   D4   D5   D6   D7  D2005 D2006 D2007 D2009 D2010  DXE  DXE2
Red LED Green LED Green LED Green LED Green LED Green LED Green LED Green LED Green LED Green LED Green LED Green LED Grey LED Grey LED

Overview

TPJCBView is a non-visual Delphi component which registers a hidden window as a "clipboard viewer".

This means that Windows notifies the component whenever the clipboard contents change. On receipt of these notifications the component triggers an event. By handling the event your application can respond to changes on the clipboard. The component can be used as the heart of a program that displays "live" information about the clipboard. Alternatively it can simply enable and disable other components whose state depends on the available clipboard formats.

TPJCBView provides an Enabled property that is used to enable and disable the component and hence it's events. It also has a TriggerOnCreation property that triggers an event when the control is created.

Documentation

The component is documented in the Clipboard Viewer Component Wiki.

Users of Delphi version 3 to 7 can also make use of the help file that is included in the download. It integrates with the Delphi 3-7 help system. The help file is a WinHelp file and therefore does not work on Windows Vista and later unless WinHelp has been downloaded and installed. See Microsoft Knowledge Base Article KB917607 for further information.

Demo program

A demo program with an associated explanatory read-me file is included in the download. The demo enables and disables a button depending on if the clipboard contains text. It can also display clipboard text in a memo.

How it works

TPJCBView works by registering its hidden window with Windows. This is accomplished by using the SetClipboardViewer API call that adds the window to the clipboard chain. The component then handles the WM_DRAWCLIPBOARD message that Windows sends to the hidden window when the clipboard changes. The WM_CHANGECBCHAIN message that indicates when the viewer chain has changed is also handled.

Two of my articles provide details of two of the key techniques used in developing this component:

Feedback

If you find any bugs or want to suggest a new feature please report them using the Issue Tracker. Be sure to tag any issues as Project-cbview. If you have created a bug fix or have implemented a new feature please attach a zip file or diff containing your source code.

If your have any other comments please contact me.