Beyond Simple Clipboard Use

We’ve seen that transferring text from the clipboard requires four calls after the data has been prepared:

OpenClipboard (hwnd) ;
EmptyClipboard () ;
SetClipboardData (iFormat, hGlobal) ;
CloseClipboard () ;

Getting access to this data requires three calls:

OpenClipboard (hwnd) ;
hGlobal = GetClipboardData (iFormat) ;
[other program lines]
CloseClipboard () ;

You can make a copy of the clipboard data or use it in some other manner between the GetClipboardData and CloseClipboard calls. That approach may be all you’ll need for most purposes, but you can also use the clipboard in more sophisticated ways.

Using Multiple Data Items

When you open the clipboard to put data into it, you must call EmptyClipboard to signal Windows ...

Get Programming Windows®, Fifth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.