Copy picture to clipboard

  1. ‹ Older
  2. 3 months ago

    Joost R

    Aug 12 Pre-Release Testers, Xojo Pro The Netherlands
    Edited 3 months ago

    As a work around I was thinking about saving the picture to a file and find a way to get the file copied into the clipboard.
    Saving is no problem, getting the file into clipboard by code is. Getting the binary stream is not the issue but put it in the clipboard in a way it's recognized as a pic ?

  3. Peter T

    Aug 14 Pre-Release Testers, Xojo Pro Oakland, CA USA

    Thanks, @Eugene D. Unfortunately, the users of our application may be pasting into any one of several target apps, not all of which can be addressed by Office Automation.

    @Joost R - This has been a long-standing problem which we worked around for years by using @ChristianSchmitz 's WindowsClipboardMBS object. For whatever reason, this stopped working as of 2017r1 or 1.1. I think Christian believes it may have to do with a change in Xojo drawing on Windows.

    "Paste Special" does work, though our users are not happy to have to take this extra step as the result of an "improvement" to our application. When we use the Xojo clipboard object, Excel always pastes the text, even if it's an empty string. Now, when we use the MBS object, Excel reports that it is unable to paste the picture data. So, there is apparently something in the Windows clipboard which tells the target to prefer the picture over the text, but the picture data put on the clipboard by the MBS code is currently somehow wrong.

    I'll sign on to the feedback case you linked to, Joost.

  4. Joost R

    Aug 15 Pre-Release Testers, Xojo Pro The Netherlands

    As of today FB 48686 says:
    "Reported fixed against Xojo2017r2."
    2017R2 release is scheduled for today. I will repeat my test on this issue tomorrow.

  5. Emile S

    Aug 15 Europe (France, Strasbourg)
    Edited 3 months ago

    Robin stand up earlier today !
    Note to self: you do not now Robin’s usual stand up time, Emile, so why do you say “earlier today“ ?

    ;-)

  6. Peter T

    Aug 15 Pre-Release Testers, Xojo Pro Oakland, CA USA

    @Joost R 2017R2 release is scheduled for today. I will repeat my test on this issue tomorrow.

    I just tested it, and for me it STILL does not work. How about you, Joost?

  7. Joost R

    Aug 15 Pre-Release Testers, Xojo Pro The Netherlands

    yes ... eh .... NO ! it's still NOT WORKING. I really don't understand why and how FB 48686 has been closed as being fixed. Just not tested in the context of the problem. And why do you have to raise a new feedback ? Just say sorry and reopen this one, it's clear enough and reproducing this issue is just 4 short lines of code and Windows up and running. (Guess the last one was not tested)

    Have you started a new one Peter ? What number ?

    There is a big chance that the solution to the problem is much more difficult than the problem looks like. According to me, the Windows clipboard doesn't take the content of a xojo picture object as a picture.
    Hopefully the team will give extra attention to this one for the next release.

  8. Peter T

    Aug 15 Pre-Release Testers, Xojo Pro Oakland, CA USA

    @Joost R - I agree, but was sick today, so have nit created a new case. Feel free if you want to; otherwise, I can tomorrow, I hope.

    Interestingly, it did work for me ONCE when I first tested, but I couldn't get it to do it again. It does work when pasting into some target apps that don't handle text (like Paint), but not Excel or Word. I think that these apps prefer text on the clipboard, even if it's an empty string. But, past behavior of WindowsClipbardMBS suggests that there is some way to get these target apps to ignore the text.

    Is there a way to actually set the clipboard's text to NIL rather than an empty string?

  9. Christian S

    Aug 16 Pre-Release Testers, Xojo Pro Germany

    Well, you can put several items on the clipboard. But if you copy only a picture, you should not include text.
    And of course the clipboard should be cleared before.

    I can look again why my Class doesn't work any more.

  10. Peter T

    Aug 16 Pre-Release Testers, Xojo Pro Oakland, CA USA

    @ChristianSchmitz And of course the clipboard should be cleared before.

    The problem with that is that as far as I can tell, there is no way to do it.

    Unlike WindowsClipboardMBS, the Xojo Clipboard object has no "clear()" method. It appears that even setting the Clipboard.text property to an empty string is seen as a valid string by various target applications, and they prefer the text over the picture.

    If you could look into why your class stopped working, it would be much appreciated.

  11. Joost R

    Aug 16 Pre-Release Testers, Xojo Pro The Netherlands

    @Peter T If you could look into why your class stopped working, it would be much appreciated.

  12. Christian S

    Aug 16 Pre-Release Testers, Xojo Pro Germany

    I spend some extra time on it and got a few new ideas.
    Maybe it's fixed now. See Emails.

  13. Christian S

    Aug 17 Pre-Release Testers, Xojo Pro Germany

    Looks like we can now get/set HBITMAP again. But it seems like some other apps can't handle that and need something different.

  14. Joost R

    Aug 17 Pre-Release Testers, Xojo Pro The Netherlands

    @ChristianSchmitz I spend some extra time on it and got a few new ideas.
    Maybe it's fixed now. See Emails.

    Got it.. Thanks. Will test later today and let you know.

  15. Christian S

    Aug 17 Pre-Release Testers, Xojo Pro Germany

    Latest version in dropbox seems to fix it.

    You may need to switch to newer setDIB function instead of setPicture.

  16. Peter T

    Aug 17 Pre-Release Testers, Xojo Pro Oakland, CA USA

    Yes it does! - at least when pasting into the target apps that our customer needs - Word, Excel, and Outlook.

    This is yet another reason I'm glad we use the MBS plugins! Thanks to everyone that has offered advice on this.

  17. Christian S

    Aug 18 Pre-Release Testers, Xojo Pro Germany

    if someone wants to try until I release next update:
    https://www.dropbox.com/sh/pefikfvg5dnum7l/AAAs2ZbeeTlYbLg95cNHu4U5a?dl=0

  18. Joost R

    Aug 18 Pre-Release Testers, Xojo Pro The Netherlands
    Edited 3 months ago

    I can copy a picture from one canvas to the clipboard and copy it from the clipboard into another canvas.

    dim p as picture = Canvas2.Backdrop
    dim c as new WindowsClipboardMBS
    c.Clear
    
    if c.SetPicture(p) then 
      speak "Copy picture"
    end if
    
    canvas3.Backdrop = c.GetPicture

    But when I look into my windows clipboard I only have a 16x16 image. I still can't copy my picture from the clipboard into MS Office.
    I took the plugin from the dropbox link above.

  19. Christian S

    Aug 18 Pre-Release Testers, Xojo Pro Germany

    Please use setDIB and getDIB methods.

  20. Joost R

    Aug 18 Pre-Release Testers, Xojo Pro The Netherlands

    Thanks Christian, using setDIB and getDIB works.
    Great... This will stay in this plugin I suppose.. ?

  21. Christian S

    Aug 18 Pre-Release Testers, Xojo Pro Germany

    Yes, of course.

or Sign Up to reply!