BBC BASIC for Windows
Programming >> User Interface >> Clipboard
http://bb4w.conforums.com/index.cgi?board=ui&action=display&num=1464861656

Clipboard
Post by KenDown on Jun 2nd, 2016, 10:00am

I'm having a problem with the clipboard, so if anyone has any experience, I'd be grateful.

Based on the various programs in the Help and the Wiki I have written this code:

size%=SUMLEN(line$())
SYS"GlobalAlloc",&2000,size%*2TOhdata%
SYS"GlobalLock",hdata%TOP%
FORi%=0TO6
line$(i%)+=CHR$13+CHR$10
$$P%=line$(i%)
P%+=LENline$(i%)
NEXT
?P%=0:P%?1=0
SYS "GlobalUnlock",hdata%
SYS "OpenClipboard",@hwnd%
SYS "EmptyClipboard"
SYS "SetClipboardData",1,hdata%
SYS "CloseClipboard"

There are precisely 7 lines (0-6) and they all end up in hdata% - I've checked. However when I do Ctrl+V only the first line comes out of the clipboard.

Incidentally - and it may be completely irrelevant - if I add all the lines together by omitting the cr and lf characters, only about 250 characters are displayed, not the 65,000+ mentioned in the Help file.

Re: Clipboard
Post by Zaphod on Jun 2nd, 2016, 3:20pm

That code works for me.
You have some extra nulls at the end of the string that aren't needed: the $$ put a null at the end of the string.

I suggest that the issue may be the place you are trying to paste to does not accept that multi-line data. Paste to Notepad should work if it is plain text.

Re: Clipboard
Post by KenDown on Jun 6th, 2016, 7:42pm

Thanks so much. Of course! Yes, it works just fine in Notepad - I was attempting to paste it into the output window from BB4W.

I was too stupid to try pasting it elsewhere. One day I'll be a real programmer!