Everything2
Near Matches
Ignore Exact
Full Text
Everything2

Clipboard

created by wharfinger

(thing) by wharfinger (6.2 y) (print)   ?   1 C! I like it! Fri Sep 15 2000 at 17:25:19

A brief warning to Win32 API people: This is intended for a non-technical audience. I'm going to simplify a bit. A hard technical writeup would (hint, hint) be a nice addition to this node. Writeups about other clipboard implementations in MacOS or whatever would be even more welcome: That's why I didn't specify an OS in the node title.

When you "copy" something in MS Windows, it usually goes in something called the "clipboard".

Okay, what's that? And why "usually"?

In Windows, the "clipboard" is a facility provided by the operating system (let's not quibble about how loosely I'm using that term here :)1. Simply put, it's a "place" where any program can put data, and where it or any other program can access that data. As for "usually", a program is not required to use the system clipboard. It can set aside its own little "place" and do the same thing with that. The problem is that other programs won't be able to access what's there. If you copy something in Notepad, it's nice to be able to paste it into Word, Netscape, or whatever. The system clipboard makes that possible.

When a program puts something in the clipboard, it provides two things: The data itself, and a "name" identifying what kind of data it is: Each kind of data is called a "clipboard format". It could be plain text, or an image, or formatted text, or just about anything. Several of these are defined by the operating system, but a program can define its own and "register" them with the operating system.

When some program wants to retrieve something from the clipboard, it can ask the operating system what formats are currently available, and then request the data for a particular format.

A program can put several different kinds of data in there at the same time if it wants to. For example, when you copy text in Word 97, it's stored in each of the following clipboard formats:

"DataObject", "Object Descriptor", "Rich Text Format", "TEXT", "UNICODETEXT", "METAFILEPICT", "Embed Source", "Native", "OwnerLink", "Link Source", "Link Source Descriptor", "ObjectLink", "Hyperlink", "OLE Private Data", "LOCALE", "OEMTEXT", and "ENHMETAFILE"

I'm not perfectly certain what half of those are for, but they're all different sorts of information about what you copied: Rich Text Format preserves the boldface, italics and so forth; "TEXT" has only the text, with no formatting. And so on and so forth. Some of them, at least, are probably specific to Word, in which case there may be no documentation available to me (barring industrial espionage) which explains what's in there .

From where the user sits, what this means is that if you copy something from Word and try to paste it into Notepad, Notepad will query the operating system and ask it if there's any "TEXT" in the clipboard. If there is, Notepad will then ask the operating system for the "TEXT" data. Now, if you try to paste into Photoshop instead, Photoshop doesn't know or care about text: It wants a picture. So Photoshop will ask the operating system about each of the image formats that Photoshop understands. If it finds one it likes, it'll request the clipboard data for that particular format, and then do the pasting as it sees fit. Try it: You can copy text from Word and paste it into Photoshop as an image. The results are crappy, but it works.

There you have the essentials. There's more: While a program is writing to the clipboard or reading from it, it "locks" the clipboard so no other program can access it at the same time. This is required because Windows is a multitasking2 operating system; if you had two programs writing to the clipboard at the same time, they'd step on each other and create a mess.

There's also usually a lot of fiddle-faddle about getting the data in the form expected for a given clipboard format. The clipboard itself doesn't care: All it sees is zeroes and ones -- but when you put random crap in the clipboard and claim that it's a "bitmap"3, it should actually be what you claim; otherwise, when a user copies an image out of your program and tries to paste it into Photoshop, Photoshop will sadly tell the user that clipboard is full of crap.




1 Not all operating systems do this (BeOS does, MacOS does; Unices don't). There are valid questions to be asked about whether an operating system has any business getting involved with it at all. I will not address those questions here2. One thing at a time.

2 If somebody wants to add a writeup discussing the issue in a reasonably even-handed and informative way, that'd be great. Don't just tell us that Microsoft sucks. Tell us why, or better yet, inform us enough that we can decide for ourselves.

3 Don't get into coding that one if you don't have some time to kill.


(thing) by Segnbora-t (16.8 hr) (print)   ?   I like it! Fri Sep 15 2000 at 21:43:25

The physical object called a clipboard is a flat sheet of some material stiff enough to press down on, with a clip of metal or plastic at one end (or occasionally one side) to hold papers. Clipboards are wonderful for writing in situations where you don't have a desk or table surface to press down on. You can often tuck writing implements into the clip and carry the clipboard and its contents easily from one place to another.

printable version
chaos

programmer's keyboard Unicode Writing to the Windows Clipboard Operating system
RTF Running a Soup Kitchen OtherMenu Reading from the Windows Clipboard
cut and paste coding user interface Ole data
The Rodent Roundup Print Screen April 17, 2003 OneClick
Dream Log: December 18, 2002 How to cut and paste in Mac OS bitmap file descriptor
ICQ styled text text Locale
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help


cooled by sensei

Cool Staff Picks
Nodes to live by:
Coincidental Correlation
Microsoft Windows
The Pogues
anthropic principle
Cloak and Dagger
How science undergoes changes of theory
Transhumanist Terminology
Ernie Kovacs
Who is allowed to donate blood?
Lee Stories
Morton Feldman
Hit by the realization that they are all getting to know you nodes
Mandelbrot set
New Writeups
Scaevola
Risk in the Roman law of sale(idea)
semicolon
overheard at IHOP(event)
choirotey
Violent pickup lines(idea)
Ouzo
Blue Ovaries, Grrrrrrwl(log)
uncljoedoc
explanation(person)
Noung
One no longer loves one's insight when one communicates it(idea)
AspieDad
Pornology(essay)
nailbiter
Nicole duFresne(person)
Simulacron3
stigmergy(idea)
nakusavi
Yesterday I learned how to kiss(idea)
aneurin
UK Local Elections 2008(event)
Phyrkrakr
Kansas City Royals(thing)
niruena
Amalric of Bena(person)
niruena
Third Crusade(event)
Ariloulaleelay
I am a female android(personal)
E2 is a by-product of the existence of The Everything Development Company