|
-
Aug 28th, 2008, 12:57 PM
#1
Thread Starter
Lively Member
[RESOLVED] [2008] how to save ClipBoard while copying?
HI All
I am crating project and I want to copy an image to clipboard and then paste it in RTB
I used this and it worked
vb Code:
Clipboard.Clear
Clipboard.SetImage("C:/Example.bmp")
document.paste
but however the old contains of the ClipBoard will cleared , so how can I copy and paste this image without lose the clipboard contain
there's two ways I found but I couldn't did them in code and don't know if they can work or not??
1-save the clipboard contain in another object or variable and them after copy paste the image bring them back to the clipboard
2-create a new clipboared
vb Code:
Dim MyClipBoard As Clipboard
but don't know how to paste from this clipboard
help me please and thanks in advance
Last edited by mahammad(); Aug 28th, 2008 at 02:30 PM.
-
Aug 28th, 2008, 01:19 PM
#2
Re: [2008] how to save ClipBoard while copying?
try this. it gets the first image from the clipboard, copies + pastes the second image, then copies the first image back to the clipboard
vb Code:
Dim img As Image = Clipboard.GetImage
Clipboard.Clear()
Clipboard.SetImage("C:/Example.bmp")
document.paste()
Clipboard.SetImage(img)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Aug 28th, 2008, 01:40 PM
#3
Thread Starter
Lively Member
Re: [2008] how to save ClipBoard while copying?
thanks .paul. for your answer but you forgot that you must save copied text too and also data and audio , right?
and I have did A small mistake in the code
I typed
vb Code:
Clipboard.Setimage("c:/Example.bmp")
and I can't type the path as string in this method so I use this
vb Code:
Clipboard.Setimage(My.Resources.Examples)
but I think that if I paste the image with another mothod not by Clipboard will be better , What do you see?
thanks
-
Aug 28th, 2008, 01:45 PM
#4
Addicted Member
Re: [2008] how to save ClipBoard while copying?
Why do you want to store data in the clipboard?
-
Aug 28th, 2008, 01:46 PM
#5
Addicted Member
Re: [2008] how to save ClipBoard while copying?
And you could do
vb Code:
Clipboard.Setimage(Image.FromFile("c:/Example.bmp"))
-
Aug 28th, 2008, 02:29 PM
#6
Thread Starter
Lively Member
Re: [2008] how to save ClipBoard while copying?
 Originally Posted by NStuff42
Why do you want to store data in the clipboard?
do you mean the image that will copied or the old data in the clipboard?
if the clipboard data just I don't want from users to lose their own data when they insert a picture to the file 
if the Image simply to paste it using 'RTB.paste()'
and is there other way to insert picture to RTB ?
thanks all
-
Aug 28th, 2008, 04:36 PM
#7
Re: [2008] how to save ClipBoard while copying?
try this. it should work with any clipboard dataformat
vb Code:
Dim data As Object = Clipboard.GetDataObject
Clipboard.Clear()
Clipboard.SetImage(Image.FromFile("c:\Example.bmp"))
document.Paste()
Clipboard.SetDataObject(data)
Last edited by .paul.; Aug 28th, 2008 at 04:43 PM.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Aug 28th, 2008, 08:49 PM
#8
Frenzied Member
Re: [2008] how to save ClipBoard while copying?
Why do you want to copy an image to the clipboard and then paste it?
What exactly are you doing? Since then you can just place it in a variable.
-
Aug 29th, 2008, 01:55 AM
#9
Thread Starter
Lively Member
Re: [2008] how to save ClipBoard while copying?
 Originally Posted by .paul.
try this. it should work with any clipboard dataformat
vb Code:
Dim data As Object = Clipboard.GetDataObject
Clipboard.Clear()
Clipboard.SetImage(Image.FromFile("c:\Example.bmp"))
document.Paste()
Clipboard.SetDataObject(data)
OK I will try it thnx
-
Aug 29th, 2008, 01:56 AM
#10
Thread Starter
Lively Member
Re: [2008] how to save ClipBoard while copying?
 Originally Posted by noahssite
Why do you want to copy an image to the clipboard and then paste it?
What exactly are you doing? Since then you can just place it in a variable.
I want to copy the image to the clipboard and paste it because it's the only method I know to insert image to RTB 
That's all I want to do just inserting image to richtextbox but is there otherway to do that please tell me
thanks
-
Aug 29th, 2008, 02:07 AM
#11
Re: [2008] how to save ClipBoard while copying?
 Originally Posted by mahammad()
I want to copy the image to the clipboard and paste it because it's the only method I know to insert image to RTB
That's all I want to do just inserting image to richtextbox but is there otherway to do that please tell me
thanks
The article at the below link explains exactly what you need.
http://www.codeproject.com/KB/edit/c...=2524851&fr=76
-
Aug 29th, 2008, 02:57 AM
#12
Thread Starter
Lively Member
Re: [2008] how to save ClipBoard while copying?
Deepak , I didn't find what I want can you show me by code?
do you mean this part of the article?
Inserting an Image
When an image is pasted into a RichTextBox (or WordPad or Microsoft Word), the image is embedded in a Windows Metafile (WMF) and the metafile is placed in the document. The InsertImage method does the same thing, but without using the clipboard. According to the RTF Specification v1.6, it is possible to insert bitmaps, JPEGs, GIFs, PNGs, and Enhanced Metafiles directly into an RTF document without first embedding them in a Windows Metafile. However, while this works with Microsoft Word, if images are not embedded in a Windows Metafile, WordPad and RichTextBox simply ignore them.
thnx
-
Aug 29th, 2008, 04:05 AM
#13
Re: [2008] how to save ClipBoard while copying?
You asked for an alternate way of inserting image in rich text box. That is why i posted that link.
-
Aug 29th, 2008, 08:02 AM
#14
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|