473,804 Members | 3,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

backup_restore clipboard

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\an sicpg1250\uc1\d eff0\" ..., but not
the formatted text.

IDataObject ido = Clipboard.GetDa taObject();
object savedData = ido.GetData(Dat aFormats.Rtf, true);
....Using clipboard for data exchange
Clipboard.SetDa taObject(savedD ata, 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
Nov 17 '05 #1
2 4312
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]
- mv*@spam.guard. caspershouse.co m

"Mészáros Tamás" <me*****@sch.bm e.hu> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
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\an sicpg1250\uc1\d eff0\" ..., but not the formatted text.

IDataObject ido = Clipboard.GetDa taObject();
object savedData = ido.GetData(Dat aFormats.Rtf, true);
...Using clipboard for data exchange
Clipboard.SetDa taObject(savedD ata, 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

Nov 17 '05 #2
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\an sicpg1250\uc1\d eff0\" ..., but not
the formatted text.


string stemp = Clipboard.GetDa taObject().GetD ata("Rich Text
Format").ToStri ng();
DataObject data = new DataObject();
data.SetData(Da taFormats.Rtf, s);
System.Windows. Forms.Clipboard .SetDataObject( data,true);
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2240
by: xyz | last post by:
I have a menu item to handle clipboard actions (cut, copy, paste). When I paste text that I copied from a Hungarian web page, the display looks normal on my RichTextBox, but the text retrieved from the clipboard is corrupted. For example, a U with double accent ( byte code x'FB' ) is replaced by a question mark in my txtEdit.Text after a Paste operation. It seems that the Clipboard.GetText() is changing the data. How is it possible to...
8
11479
by: LG | last post by:
Just have a question with regards to the clipboard, and how to read what other applications (Adobe InDesignCS) place in the clipboard. I am currently in the process of creating a booklet from a database, and I need the data to be laid out in a tabular format, and set out in a specific way. At the current point in time, I am copy/pasting the raw text from the database into a table layout in InDesign. What I was thinking is that if I could...
7
11645
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard is proving to be more difficult. These pictureboxes are bound to an AccessDB. If the user wants to add an image, they select an image using an OpenFileDialog: Dim result As DialogResult = Pic_Sel.ShowDialog() If (result = DialogResult.OK) Then
0
1908
by: James Russo | last post by:
Hello, I have an application which requires an image to be retrived from the clipboard. So, I am writting a quick C# windows application to take images from a webcam and store a single frame on the clipboard so it can be pasted into this other application. My solution is working fine with all applications (mspaint, word, wordpad) except the one I need it to work with. I've contacted the vendor of the application, but I haven't been able...
7
3856
by: Newbie | last post by:
How do I clear the clipboard in VB.NET 2003? TIA Newbie
15
12305
by: Peter Duniho | last post by:
I'm trying to use .NET and C# to draw a metafile copied to the clipboard by another application (Word 2003 in this case, but it shouldn't matter). I naively thought that I'd be able to use the Clipboard class to get an EnhancedMetafile or MetafilePict object from the Clipboard, use that to create a new Metafile object, and then draw that Metafile object using Graphics.DrawImage. It doesn't seem to be that simple.
1
18675
by: Figmo | last post by:
Wow.....this is darned odd.... I have an app that integrates with other applications. It registers a global hotkey with Windows. When the hotkey executes it sends a CTRL-C to the active window (any application) to copy whatever text is selected to the clipboard. It then issues a C# Clipboard.GetText(...) and does some processing with this string. All is good, no errors thus far.
8
2506
by: active | last post by:
Guess I'm looking for someone who likes to work difficult puzzles. I can't seem to ever retrieve a palette handle from the clipboard. Below is a simple test program that demonstrates the problem. The program uses windows api to get a handle to a palette from the clipboard. The palette needs to be put there by another program - maybe Photoshop.
20
7019
by: Joe Duchtel | last post by:
Hello - I have the following code to get a bitmap from the clipboard and to save it to a *.png file ... Dim lData As IDataObject = Clipboard.GetDataObject() If lData.GetDataPresent(DataFormats.Bitmap) Then Dim lPictureBox As New PictureBox
0
9705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9576
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10311
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9138
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.