Is there any way to store two different things in Clipboard like text & picture at the same time safely..?
Printable View
Is there any way to store two different things in Clipboard like text & picture at the same time safely..?
You can't store both. Try selecting the text of a webpage with a few picture on it and copying it, it won't work. The only way is to probably hook the Control+V and Paste commands and set each item to the clipboard before pasting.
Phreak
Quote:
Originally Posted by «°°phReAk°°»
hmm phReaAk
it means Clipboard cannot be multidimensional in any sense.
if i will hook paste commands then problem will remain the same that i wan to different things at a time in Clipboard Object. :rolleyes:
Technically, they wouldn't be on the clipboard at all. I'd have a program with picturebox arrays and string arrays. When the user wants to copy both a picture and text to the clipboard, they are instead moved to the pictureboxes and arrays. Then when you hook the keys, whenever they paste, you paste each item, 1 by 1, moving them from arrays/pictureboxes to the clipboard, and pasting.
Phreak
Ok u mean i can solve this problem by using array of picture boxes and strings.
Quite possibly. I might type you up a quick example (- the windows keys hooks), bare with me..
Phreak
yup it could be helpful
Something like this. It's basic, but you can add control arrays for the pictures, if you want more than 1 picture "on the clipboard".
Phreak
yup it proves to be helpful.
Now there is one problem
...and that problem would be?
Phreak
oh sorry to mention
it is that
clipboard object is already occupied by another application .
Now i want to copy my text or picture into clipboard and want to retrieve it as well while keeping anything which is in clipboard object before i used clipboard.
thx phReAk for contributing.
In that case, just check what is on the clipboard, then store it.
..paste your things, then reset the old contents back to the clipboard.VB Code:
Dim cbFMT As Boolean, cbFMT2 As Boolean cbFMT = Clipboard.GetFormat(vbCFText) 'is it text? cbFMT2 = Clipboard.GetFormat(vbCFBitmap) 'is it a picture? If (cbFMT) Then 'it is text! StoreString = Clipboard.GetText ElseIf (cbFMT2) Then 'it is a picture StorePictureBox.Picture = Clipboard.GetData End If
Phreak
Set up another variable (or two a string and a picture) for storing the contents of the clipboard before you put yours in.Quote:
Originally Posted by vbPoet
thx phReAk
Ok if it would be string i will store it in string variable..
But if it is neither picture nor text .. then ....??
would picturebox.picture will work in that situation ...?
did u understand my last post ..?
What else would it be? You mean, files?
Phreak
yup it could be files or movies or sound or anything anything ......
Some time strange thing happen to me..
if i have not opened Vb IDE and copied some source code.. then open IDE and want to paste it ... Nothing apperars and PASTE button is disabled.
So i have to copy source while keeping Open IDE and then i m able to paste it..
So what is that ......
Is it related to my previous post theme ..?
I have modified it little.
Check third line under command1 click event ...
and do the following.
copy some text from RTB and then ctrl +v it ..
and then click COPY TO CLIPBOARD ..
again when you will ctrl +V it will not display any picture instead it will display old text which u have copied by ctrl +c ..
i want to know
what 3rd line under command1 click event is doing in that case ..
y it is not working .. :o
I think its because of this:
vbBitmap won't do it, it needs to be..VB Code:
Private Sub Command1_Click() Picture2.Picture = Picture1.Picture str = Text1.Text Clipboard.SetData Picture2.Picture, vbBitmap End Sub Private Sub Command2_Click() Clipboard.SetData Picture2.Picture, vbBitmap SendMessage RichTextBox1.hwnd, WM_PASTE, 0&, 0& Clipboard.Clear Clipboard.SetText str SendMessage RichTextBox1.hwnd, WM_PASTE, 0&, 0& End Sub
PhreakVB Code:
Private Sub Command1_Click() Picture2.Picture = Picture1.Picture str = Text1.Text Clipboard.SetData Picture2.Picture, [b]vbCFBitmap[/b] End Sub Private Sub Command2_Click() Clipboard.SetData Picture2.Picture, [b]vbCFBitmap[/b] SendMessage RichTextBox1.hwnd, WM_PASTE, 0&, 0& Clipboard.Clear Clipboard.SetText str SendMessage RichTextBox1.hwnd, WM_PASTE, 0&, 0& End Sub
Also, having a Clipboard.Clear statement in the Copy to Clipboard sub will help:
PhreakVB Code:
Private Sub Command1_Click() Picture2.Picture = Picture1.Picture str = Text1.Text [b]Clipboard.Clear[/b] Clipboard.SetData Picture2.Picture, vbCFBitmap End Sub
The developers of VB (or the VB IDE ?), built in (or left out) something.Quote:
Some time strange thing happen to me..
if i have not opened Vb IDE and copied some source code.. then open IDE and want to paste it ... Nothing apperars and PASTE button is disabled.
So i have to copy source while keeping Open IDE and then i m able to paste it..
So what is that ......
There is a bug, which means it does not interact correctly with the clipboard.
I have noticed many times, that things aint there (in Clipboard) when I expect them.
It works fine for me when I made the changes listed above.
Phreak
I haven't been following the thread.
The bit I noticed and replied to, I suspected was an observation not directly related to this thread. I had seen confirmation that a bug existed, and I was just pointing that out.
I think it was not related to the solution you are talking about.
Ah ok. Has anyone checked the M$ website lately? Is there a service pack for the IDE or something to fix this bug? Sorry for the un-relevance (sp?) to this thread.
Phreak
Anyways it was related to my problem ...Thx for telling me that it is M$ another BUG..
Nopz phReAk it didn't work.. same problem is persisting...
it is pasting old text
I need a step by step of what you are doing to create the problem. What I thought you meant I fixed.
Step by step :p
Phreak
It is step by step
:p
Quote:
Originally Posted by vbPoet
***********
Now i have replace VBBitmap to vbCFBitmap ....
but same problem is persisting ... :wave:
More step by step ...........?? lolz
Does PictureBox wise enough to handle all these things...?Quote:
Originally Posted by vbPoet