Chapter 12 -- The Clipboard

Chapter 12

The Microsoft 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. Windows 98 and Microsoft Windows NT come with Clipboard Viewer programs that show the current contents of the clipboard.

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, usually text, a bitmap (a rectangular array of bits that correspond to the pixels of a display surface), or a metafile (a binary collection of drawing commands). 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 (or a Ctrl-X or Ctrl-C) operation in one program should be able to assume that the data will remain in the clipboard until the next Cut or Copy operation.

You may recall that an Edit menu was implemented in the later versions of the POPPAD programs shown in Chapters 10 and 11. However, that simply involved sending messages to the edit control. In most cases you don't have that convenience; you must instead call the clipboard transfer functions yourself.

This chapter will focus on transferring text to and from the clipboard. In later chapters, I'll show you how to use the clipboard with bitmaps (Chapters 14, 15, and 16) and metafiles (Chapter 18).



Programming Windows
Concurrent Programming on Windows
ISBN: 032143482X
EAN: 2147483647
Year: 1998
Pages: 112
Authors: Joe Duffy

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net