473,399 Members | 2,478 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,399 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 4788
"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, 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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.