tags:

views:

80

answers:

2

What control can display clipboard items and files? I would like the items and files to be able to pasted on selection. And how do I set it so that history of items is shown and the program remembers the items copied on the clipboard.


Sorry, I changed my mind to WinForms. I heard that WPF has a very steep learning curve, and since I am already proficient in WinForms, no point in changing to WPF until I have learn much about it.

A: 

The Windows clipboard can only contain 1 item, not the history of copied items. So your application has to handle that manually, by monitoring clipboard activity, as explained here. Note that in WPF, you can't override the WndProc method, so you need to register a hook to process Windows messages using HwndSource.AddHook.

When you receive a WM_DRAWCLIPBOARD notification, you can access the clipboard data using the Clipboard class, and do whatever you need to do with it.

Note that there's a known bug with images in the WPF clipboard, I describe a solution here

Thomas Levesque
+3  A: 

See How to: Retrieve Data from the Clipboard

To determine whether the Clipboard contains data in a particular format, use one of the ContainsFormat methods or the GetData method. To retrieve data from the Clipboard, use one of the GetFormat methods or the GetData method.

KMan
+1 For giving a link to that very subject on MSDN.
Jason D