Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to place multiple formats on the clipboard?

For example, what Wordpad did when I press "Ctrl+C"? It places many different format to clipboard. So Notepad can get the text without any color or font...etc, and you still can keep the original format when you paste in another Wordpad window.

The MSDN said I should call SetClipboardData multiple times. But it doesn't work at all.

like image 452
trudger Avatar asked Apr 21 '10 17:04

trudger


2 Answers

You can use Delphi's TClipboard.SetAsHandle to put data on the clipboard in as many formats as you want. Open the clipboard first, or else each call to SetAsHandle will clobber whatever else was already there, even in other formats.

Clipboard.Open;
Clipboard.SetAsHandle(cf_Text, x);
Clipboard.SetAsHandle(cf_Bitmap, y);
Clipboard.Close;
like image 179
Rob Kennedy Avatar answered Sep 25 '22 13:09

Rob Kennedy


All modern programs use OleSetClipboard to publish clipboard formats and data. Start reading here.

like image 44
Hans Passant Avatar answered Sep 24 '22 13:09

Hans Passant