PART 5 DATA EXCHANGE AND LINKS

Chapter 16 The Clipboard

The Windows clipboard allows data to be transferred from one program to another. It is a relatively simple mechanism that doesn't require much overhead in either the program that places data in the clipboard or the program that later gets access to it.

Let's clear up one possible point of confusion right away: The CLIPBOARD program that comes with Windows is not the clipboard. It is instead a ”clipboard viewer“ that displays the current contents of the clipboard. (We'll write our own simple clipboard viewer later in this chapter.) The clipboard is simply a series of functions in Windows' USER module that facilitate the exchange of memory blocks between programs.

Many programs that deal with documents or other data include an Edit menu with the options Cut, Copy, and Paste. When a user selects Cut or Copy, the program transfers data from the program to the clipboard. This data is in a particular format, such as text, a bitmap, or a metafile. When a user selects Paste from the menu, the program determines if the clipboard contains data in a format that the program can use and, if so, transfers data from the clipboard to the program.

Programs should not transfer data into or out of the clipboard without an explicit instruction from the user. For example, a user who performs a Cut or a Copy operation in one program should be able to assume that the data will remain in the clipboard until the next Cut or Copy operation or until the user employs a program—such as the BLOWUP2 presented in this chapter—specifically designed to manipulate the clipboard.