Page 1 of 1

Using clipboard to copy text to Notepad

Posted: Fri Apr 03, 2020 8:23 am
by reganc
I have done some quick code that I thought would just work, but for some reason it doesn't.

Code: Select all

   cText := Get_Report_As_Text()
   oClipBoard := XbpClipboard():new():create()
   oClipBoard:open()
   oClipBoard:setBuffer(cText,XBPCLPBRD_TEXT)
   if oClipBoard:getBuffer(XBPCLPBRD_TEXT) == cText
      lOk:=.t.
   endif
   oClipBoard:close()
   oClipBoard:destroy()
   my_alert("Text "+iif(lOk,"","cannot be ")+"copied to clipboard"+iif(lOk," Ok",""))
The Get_Report_As_Text() does return lines of text with carriage return + linefeed line endings (I checked that).

But when I run it and after the alert appears I go to my Notepad window and paste and instead of the text I was expecting I get some bit of code I copied earlier in the day.

Can anyone see anything wrong? Or am I wrong in assuming that the Xbase++ clipboard can be used by other Windows programs?

Re: Using clipboard to copy text to Notepad

Posted: Fri Apr 03, 2020 9:03 am
by rdonnay
I got it to work only after calling oClipboard:clear() after oClipBoard:open()

Re: Using clipboard to copy text to Notepad

Posted: Mon Apr 06, 2020 1:20 am
by reganc
rdonnay wrote:I got it to work only after calling oClipboard:clear() after oClipBoard:open()
You the man! Thanks, Roger, works perfectly.

I wonder if Alaska acknowledged this as a problem? If so, I can't see any mention of it...