erictioh Posted April 22, 2006 Posted April 22, 2006 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? Quote
erictioh Posted April 22, 2006 Author Posted April 22, 2006 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? Quote
Leaders snarfblam Posted April 23, 2006 Leaders Posted April 23, 2006 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. Quote [sIGPIC]e[/sIGPIC]
erictioh Posted April 24, 2006 Author Posted April 24, 2006 ok, sounds logic. so how should i backup and restore the clipboard? Quote
Administrators PlausiblyDamp Posted April 24, 2006 Administrators Posted April 24, 2006 There probably is no reliable way to do this as the format of the data is very dependant on the application that created it. It may help if you say why you are needing to do this as there may be an alternate solution to the problem. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.