473,237 Members | 1,416 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,237 software developers and data experts.

Clipboard copy and paste

Any source code example I can use to save the clipboard content to an
object, then I will do a copy and paste, finally put back the 'saved'
clipboard content back to clipboard ?
Dec 6 '06 #1
9 4778
"Alan T" <al*************@yahoo.com.auwrote in message
news:ux**************@TK2MSFTNGP06.phx.gbl...
Any source code example I can use to save the clipboard content to an
object, then I will do a copy and paste, finally put back the 'saved'
clipboard content back to clipboard ?
Are you trying to use the clipboard to exchange data without the user doing
a copy-paste themselves?
>

Dec 6 '06 #2
Use the System.Windows.Forms.Clipboard class and its static function.

Clipboard.GetDataObject(); returns the data that is currently in the
clipboard
Clipboard.SetDataObject("Test test"); allow you to put data in the
clipboard

there are also other usefull static functions to see what kind of data
you have in your clipboard!
ps: MSDN is the solution!

Alan T wrote:
Any source code example I can use to save the clipboard content to an
object, then I will do a copy and paste, finally put back the 'saved'
clipboard content back to clipboard ?
Dec 6 '06 #3
Hello Alan,
>Any source code example I can use to save the clipboard content to an
object, then I will do a copy and paste, finally put back the 'saved'
clipboard content back to clipboard ?
Let me just quickly say that I hate it when applications do this. If you
ask me, the clipboard is supposed to be an interactive functionality and I
(as the user) should be the only one to decide what's in the clipboard.

I have a real reason for this aversion, apart from principle: I'm using a
clipboard monitor tool (ClipMate), and in conjunction with applications
that modify the content of the clipboard for their own purposes, such
tools regularly go haywire - the clipboard content is being changed
several times in a very short timeframe, the tool tries to copy all the
content aside for later reuse, and so on. And in the end I have all kinds
of stuff in my clipboard history database that I can't really do anything
useful with.

Maybe I'm misunderstanding what you're trying to do, in that case please
forgive my rant :-)
Oliver Sturm
--
http://www.sturmnet.org/blog
Dec 6 '06 #4
What I am trying to do is my application will do a copy some text/graphics
into clipboard and paste to another document.

By exiting my application, I need to restore the clipboard status as before
my application started.
So the pc user does not know his clipboard has been changed.

"Oliver Sturm" <ol****@sturmnet.orgwrote in message
news:xn****************@msnews.microsoft.com...
Hello Alan,
>>Any source code example I can use to save the clipboard content to an
object, then I will do a copy and paste, finally put back the 'saved'
clipboard content back to clipboard ?

Let me just quickly say that I hate it when applications do this. If you
ask me, the clipboard is supposed to be an interactive functionality and I
(as the user) should be the only one to decide what's in the clipboard.

I have a real reason for this aversion, apart from principle: I'm using a
clipboard monitor tool (ClipMate), and in conjunction with applications
that modify the content of the clipboard for their own purposes, such
tools regularly go haywire - the clipboard content is being changed
several times in a very short timeframe, the tool tries to copy all the
content aside for later reuse, and so on. And in the end I have all kinds
of stuff in my clipboard history database that I can't really do anything
useful with.

Maybe I'm misunderstanding what you're trying to do, in that case please
forgive my rant :-)
Oliver Sturm
--
http://www.sturmnet.org/blog

Dec 6 '06 #5
"Alan T" <al*************@yahoo.com.auwrote in message
news:eV**************@TK2MSFTNGP02.phx.gbl...
What I am trying to do is my application will do a copy some text/graphics
into clipboard and paste to another document.

By exiting my application, I need to restore the clipboard status as
before my application started.
So the pc user does not know his clipboard has been changed.
The clipboard changes the moment you copy some data to it. Unless you have
some way to prevent the user from using his computer until your application
exits, you still have the risk of the user knowing that his clipboard has
been changed (and in particular, without his knowledge or consent and
possibly trashing, even if only temporarily, important data that he put
there on purpose).

Oliver's comments are exactly right. It is not appropriate to change the
clipboard without the user's explicit instruction. If you need to move data
from one document to another without the user's intervention, you need to do
so without using the clipboard. There should be no need to use the
clipboard anyway, and there are very good reasons not to for this purpose.

Pete
Dec 6 '06 #6
On Thu, 7 Dec 2006 10:26:09 +1100, "Alan T" <al*************@yahoo.com.au>
wrote:
>What I am trying to do is my application will do a copy some text/graphics
into clipboard and paste to another document.

By exiting my application, I need to restore the clipboard status as before
my application started.
So the pc user does not know his clipboard has been changed.

"Oliver Sturm" <ol****@sturmnet.orgwrote in message
news:xn****************@msnews.microsoft.com...
>Hello Alan,
>>>Any source code example I can use to save the clipboard content to an
object, then I will do a copy and paste, finally put back the 'saved'
clipboard content back to clipboard ?

Let me just quickly say that I hate it when applications do this. If you
ask me, the clipboard is supposed to be an interactive functionality and I
(as the user) should be the only one to decide what's in the clipboard.

I have a real reason for this aversion, apart from principle: I'm using a
clipboard monitor tool (ClipMate), and in conjunction with applications
that modify the content of the clipboard for their own purposes, such
tools regularly go haywire - the clipboard content is being changed
several times in a very short timeframe, the tool tries to copy all the
content aside for later reuse, and so on. And in the end I have all kinds
of stuff in my clipboard history database that I can't really do anything
useful with.

Maybe I'm misunderstanding what you're trying to do, in that case please
forgive my rant :-)
Oliver Sturm
--
http://www.sturmnet.org/blog
Hmmmm..... I think I agree with Oliver. I don't want any applications copying
data from my documents to another without my knowledge....

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Dec 7 '06 #7
Sorry, I need to make myself clear:

In my application, I will create a new document.
The application will copy a part of another document (this will occupy the
clipboard) and paste to the new document.
Then application exit.

I need to restore the clipboard so that the pc user still keep the clipboard
content before the application started.

"Peter Duniho" <Np*********@NnOwSlPiAnMk.comwrote in message
news:12*************@corp.supernews.com...
"Alan T" <al*************@yahoo.com.auwrote in message
news:eV**************@TK2MSFTNGP02.phx.gbl...
>What I am trying to do is my application will do a copy some
text/graphics into clipboard and paste to another document.

By exiting my application, I need to restore the clipboard status as
before my application started.
So the pc user does not know his clipboard has been changed.

The clipboard changes the moment you copy some data to it. Unless you
have some way to prevent the user from using his computer until your
application exits, you still have the risk of the user knowing that his
clipboard has been changed (and in particular, without his knowledge or
consent and possibly trashing, even if only temporarily, important data
that he put there on purpose).

Oliver's comments are exactly right. It is not appropriate to change the
clipboard without the user's explicit instruction. If you need to move
data from one document to another without the user's intervention, you
need to do so without using the clipboard. There should be no need to use
the clipboard anyway, and there are very good reasons not to for this
purpose.

Pete

Dec 7 '06 #8
"Alan T" <al*************@yahoo.com.auwrote in message
news:uU**************@TK2MSFTNGP02.phx.gbl...
Sorry, I need to make myself clear:

In my application, I will create a new document.
The application will copy a part of another document (this will occupy the
clipboard) and paste to the new document.
Then application exit.
Well, the various comments still apply. Your application should not be
automatically invoking the clipboard without the user's intervention,
assuming it is running in an environment where there is actually a user to
intervene.

If there is no such user, then preserving the clipboard is not important.
If there is such a user, then the operation should occur only through the
explicit and manual actions of the user.

Pete
Dec 7 '06 #9
>>Hmmmm..... I think I agree with Oliver. I don't want any applications
>>copying
data from my documents to another without my knowledge....
Sorry, I think you are talking about rational things.

I want to be in a technical side or programming matters.
The end user knows he is copying part of a document to another document, ie
merge the documents, this is what my application supposed to do. These
things are behind the scenes. There are many things in the modern days
application without the user's notice.
The document is not what you think the user's document, that's part of the
application only specified by the user in the application.
Dec 7 '06 #10

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

Similar topics

0
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...
5
by: tabonni | last post by:
Hello All I am creating an ASP page. There are a list of filename and checkbox next to it. When user checked all the documents they want and click ADD TO CLIPBOARD button. All filepaths will be...
0
by: Christopher | last post by:
Hello, First, I appologize for the length but I want to get all the facts down so as not to waste any time :) I'm trying to allow the user of my C# app to copy a DataGrid full of double values...
5
by: DraguVaso | last post by:
Hi, I'm looking for a way to Copy and Paste Files to the clipboard. I found a lot of articles to copy pieces of text and bitmaps etc, but nog whole files. Whay I need is like you have in...
7
by: lgbjr | last post by:
Hello All, Im 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...
8
by: serge calderara | last post by:
Dear all, I have an treeview control with different node object, I would like to implement the Copy/Paste function of an object . For that I am using the folowing function to copy teh object to...
15
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...
1
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...
2
by: toronto | last post by:
Seasons Greetings Everyone! I want to use JavaScript's event object to detect whether someone has pressed the 'PrintScreen' key to screenshot, via the Windows Clipboard, and to print website...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.