How to copy image and text to clipboard as one object?

I am trying to copy both an image from a file and text from a file to the clipboard. My intention is to open a text document or Outlook email and paste both text and image into one standard paste command (e.g. CTRL-V). I can do both separately easily enough, but doing them as in one operation does not seem to work.

This is how these two work for me as separate operations (only corresponding lines of code, of course, with disabling try / catch, etc.):

Add image to clipboard:

...

Bitmap imageToAdd = new Bitmap(imageFilePath);
Clipboard.SetImage(imageToAdd);

...

Add text to clipboard:

...

StreamReader rdr = new StreamReader(textFilePath);
string text = rdr.ReadToEnd();

Clipboard.SetText(text);

...

I use the framework of C # and .net 2.0 and focus on Windows XP (and probably Vista in the near future).

TIA

+5
3

, .

, , .

, .

+1

RTF, . , CF_BITMAP CF_TEXT . . , Paint, , . . - , , Star Trek, . .

+4

Maybe you can use SetDataObject, which requires an Object parameter, can you use an array of objects?

An array of objects can store the required data.

See this link:

http://msdn.microsoft.com/en-us/library/5b8kt5z4.aspx

+1
source

All Articles