PC Review


Reply
Thread Tools Rate Thread

backup_restore clipboard

 
 
=?ISO-8859-1?Q?M=E9sz=E1ros_Tam=E1s?=
Guest
Posts: n/a
 
      23rd Mar 2005
Hi!

Can I save and restore the content of the clipboard without dealing with
the format it stores? I use the clipboard for data exchange between
applications (this is the only way), and I would like to keep the
previous content of the clipboard. Any examples I've found build on the
format of the data, but I can't now in advance, what type of data on the
clipboard will be. I can't even save and restore a part of simple
formatted text copied from winword. If I choose text format, I get
unformatted text back. If I choose Rich Text Format, I get the rtf
formatting text (eg. "{\rtf1\ansi\ansicpg1250\uc1\deff0\" ..., but not
the formatted text.

IDataObject ido = Clipboard.GetDataObject();
object savedData = ido.GetData(DataFormats.Rtf, true);
....Using clipboard for data exchange
Clipboard.SetDataObject(savedData, true);

And what if there is a bitmap or other kind of data on the clipboard?
How could I save and restore them?

Could someone send me a link where I could find solution for my problem,
or tell me what I could do?

Thank's

Tamas Meszaros
 
Reply With Quote
 
 
 
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      23rd Mar 2005
Mészáros,

Once you get the implementation of IDataObject, you should be able to
call GetFormats to get all the formats that are on the clipboard. Once you
have those, cycle through them, and get the data, and store it somewhere.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (E-Mail Removed)

"Mészáros Tamás" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi!
>
> Can I save and restore the content of the clipboard without dealing with
> the format it stores? I use the clipboard for data exchange between
> applications (this is the only way), and I would like to keep the previous
> content of the clipboard. Any examples I've found build on the format of
> the data, but I can't now in advance, what type of data on the clipboard
> will be. I can't even save and restore a part of simple formatted text
> copied from winword. If I choose text format, I get unformatted text back.
> If I choose Rich Text Format, I get the rtf formatting text (eg.
> "{\rtf1\ansi\ansicpg1250\uc1\deff0\" ..., but not the formatted text.
>
> IDataObject ido = Clipboard.GetDataObject();
> object savedData = ido.GetData(DataFormats.Rtf, true);
> ...Using clipboard for data exchange
> Clipboard.SetDataObject(savedData, true);
>
> And what if there is a bitmap or other kind of data on the clipboard? How
> could I save and restore them?
>
> Could someone send me a link where I could find solution for my problem,
> or tell me what I could do?
>
> Thank's
>
> Tamas Meszaros



 
Reply With Quote
 
Denny Britz
Guest
Posts: n/a
 
      23rd Mar 2005
Hi,

> I've found build on the
> format of the data, but I can't now in advance, what type of data on the
> clipboard will be. I can't even save and restore a part of simple
> formatted text copied from winword.


ido.GetFormats(true) returns a string-array of all supported datatypes.
You can iterate through them and decide which one to choose.


> If I choose text format, I get
> unformatted text back. If I choose Rich Text Format, I get the rtf
> formatting text (eg. "{\rtf1\ansi\ansicpg1250\uc1\deff0\" ..., but not
> the formatted text.


string stemp = Clipboard.GetDataObject().GetData("Rich Text
Format").ToString();
DataObject data = new DataObject();
data.SetData(DataFormats.Rtf, s);
System.Windows.Forms.Clipboard.SetDataObject(data,true);
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Transfer clipboard from Task pane clipboard(office?) content to Excel (windows?) clipboard? tskogstrom Microsoft Excel Programming 2 6th Mar 2007 12:50 PM
Clipboard gets empty by itself, cleared clipboard, copy paste doesn't work, outlook clears clipboard, problems with clipboard - possible solution Jens Hoerburger Microsoft Outlook 0 24th Aug 2006 02:44 PM
Increase clipboard entries; find clipboard that holds multiples Chad Harris Windows XP Customization 3 28th Oct 2005 02:13 AM
How do I disable Office Clipboard so Copy Paste uses traditional Windows Clipboard dwilliamson@ivsi.com Microsoft Excel Discussion 10 24th Feb 2005 02:36 PM
Problems with clipboard : system.runtime.interopservices : The requested clipboard operation failed Dennis Microsoft C# .NET 0 5th Apr 2004 06:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:25 AM.