Results 1 to 31 of 31

Thread: Two things in Clipboard

  1. #1

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Two things in Clipboard

    Is there any way to store two different things in Clipboard like text & picture at the same time safely..?

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Two things in Clipboard

    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

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Two things in Clipboard

    Quote Originally Posted by «°°phReAk°°»
    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

    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.

  4. #4
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Two things in Clipboard

    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

    Visual Studio 6, Visual Studio.NET 2005, MASM

  5. #5

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Two things in Clipboard

    Ok u mean i can solve this problem by using array of picture boxes and strings.

  6. #6
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Two things in Clipboard

    Quite possibly. I might type you up a quick example (- the windows keys hooks), bare with me..

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  7. #7

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Two things in Clipboard

    yup it could be helpful

  8. #8
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Two things in Clipboard

    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
    Attached Files Attached Files

    Visual Studio 6, Visual Studio.NET 2005, MASM

  9. #9

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Two things in Clipboard

    yup it proves to be helpful.
    Now there is one problem

  10. #10
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Two things in Clipboard

    ...and that problem would be?

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  11. #11

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Two things in Clipboard

    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.

  12. #12
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Two things in Clipboard

    In that case, just check what is on the clipboard, then store it.
    VB Code:
    1. Dim cbFMT As Boolean, cbFMT2 As Boolean
    2.  
    3. cbFMT = Clipboard.GetFormat(vbCFText) 'is it text?
    4. cbFMT2 = Clipboard.GetFormat(vbCFBitmap) 'is it a picture?
    5. If (cbFMT) Then
    6.     'it is text!
    7.     StoreString = Clipboard.GetText
    8. ElseIf (cbFMT2) Then
    9.     'it is a picture
    10.     StorePictureBox.Picture = Clipboard.GetData
    11. End If
    ..paste your things, then reset the old contents back to the clipboard.

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  13. #13
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Two things in Clipboard

    Quote Originally Posted by vbPoet
    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.
    Set up another variable (or two a string and a picture) for storing the contents of the clipboard before you put yours in.

  14. #14

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Two things in Clipboard

    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 ...?

  15. #15

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Two things in Clipboard

    did u understand my last post ..?

  16. #16
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Two things in Clipboard

    What else would it be? You mean, files?

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  17. #17

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Two things in Clipboard

    yup it could be files or movies or sound or anything anything ......

  18. #18

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Two things in Clipboard

    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 ..?

  19. #19

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Two things in Clipboard

    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 ..
    Attached Files Attached Files

  20. #20
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Two things in Clipboard

    I think its because of this:
    VB Code:
    1. Private Sub Command1_Click()
    2. Picture2.Picture = Picture1.Picture
    3. str = Text1.Text
    4. Clipboard.SetData Picture2.Picture, vbBitmap
    5. End Sub
    6.  
    7. Private Sub Command2_Click()
    8. Clipboard.SetData Picture2.Picture, vbBitmap
    9. SendMessage RichTextBox1.hwnd, WM_PASTE, 0&, 0&
    10. Clipboard.Clear
    11. Clipboard.SetText str
    12. SendMessage RichTextBox1.hwnd, WM_PASTE, 0&, 0&
    13. End Sub
    vbBitmap won't do it, it needs to be..
    VB Code:
    1. Private Sub Command1_Click()
    2. Picture2.Picture = Picture1.Picture
    3. str = Text1.Text
    4. Clipboard.SetData Picture2.Picture, [b]vbCFBitmap[/b]
    5. End Sub
    6.  
    7. Private Sub Command2_Click()
    8. Clipboard.SetData Picture2.Picture, [b]vbCFBitmap[/b]
    9. SendMessage RichTextBox1.hwnd, WM_PASTE, 0&, 0&
    10. Clipboard.Clear
    11. Clipboard.SetText str
    12. SendMessage RichTextBox1.hwnd, WM_PASTE, 0&, 0&
    13. End Sub
    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  21. #21
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Two things in Clipboard

    Also, having a Clipboard.Clear statement in the Copy to Clipboard sub will help:
    VB Code:
    1. Private Sub Command1_Click()
    2. Picture2.Picture = Picture1.Picture
    3. str = Text1.Text
    4. [b]Clipboard.Clear[/b]
    5. Clipboard.SetData Picture2.Picture, vbCFBitmap
    6. End Sub
    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  22. #22
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: Two things in Clipboard

    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 ......
    The developers of VB (or the VB IDE ?), built in (or left out) something.
    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.
    Rob C

  23. #23
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Two things in Clipboard

    It works fine for me when I made the changes listed above.

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  24. #24
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: Two things in Clipboard

    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.
    Rob C

  25. #25
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Two things in Clipboard

    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

    Visual Studio 6, Visual Studio.NET 2005, MASM

  26. #26

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Two things in Clipboard

    Anyways it was related to my problem ...Thx for telling me that it is M$ another BUG..

  27. #27

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Two things in Clipboard

    Nopz phReAk it didn't work.. same problem is persisting...
    it is pasting old text

  28. #28
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Two things in Clipboard

    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

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  29. #29

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Two things in Clipboard

    It is step by step

    Quote Originally Posted by vbPoet
    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 ..

    ***********
    Now i have replace VBBitmap to vbCFBitmap ....
    but same problem is persisting ...

  30. #30

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Two things in Clipboard

    More step by step ...........?? lolz

  31. #31

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Two things in Clipboard

    Quote Originally Posted by vbPoet
    yup it could be files or movies or sound or anything anything ......
    Does PictureBox wise enough to handle all these things...?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width