Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

how do i backup clipboard data? meaning i don't care what kind of format is currently stored in clipboard, but i just want to backup it to a variable or something?

 

after backup i got to do something with it, after that it's time to restore the prevly backed up data back to clipboard. how to restore it?

 

anyone know how to do these in vb.net?

Posted

i;ve found a weird problem.

 

'backup clipboard

dim backup = Clipboard.GetDataObject()

Dim o As New Object

Clipboard.SetDataObject(o) 'Clear clipboard (confirm working)

 

'restore clipboard

Clipboard.SetDataObject(backup)

 

these codes works for filedrop format but not text format.

what i do is this :

i open notepad and type some text in, then highlight and copy them. after that i run the backup portion of code above, then yeah the clipboard is not empty. after that i run the restore portion of code then suppose it has been restored back to clipboard but when i right click on notepad i've found that the 'paste' word exist but when i paste nothing pasted.

but indeed i run another code:

 

Clipboard.GetDataObject.GetDataPresent(Dataformats.text)

it returns true, that mean there are text exist in clipboard, but the text is somehow corrupted and cannot be paste to notepad.

 

ok, as i said it works for filedrop, means when i copy a file, eg. abc.mp3, then i backup it, and restore it the mp3 file in clipboard still exist as before.

 

 

why it's not working for text?

 

code for backup and restore attached.. can anyone test it out and tell me why text format cannot be backup and restore?

  • Leaders
Posted
I would not recommend trying to save the IDataObject from the clipboard in the first place. The object returned by the ClipBoard.GetDataObject is not the data itself, but an object that will get you that data (it may or may not store the data internally, I couldn't tell you). Without doing any research, I would guess that when the clipboard data is replaced, the behavior of the old IDataObject is not defined and becomes unpredictable.
[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...