SetClipBoardData()

Share your advanced PureBasic knowledge/code with the community.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

SetClipBoardData()

Post by BackupUser »

Code updated for 5.20+ (same as SetClipboardText())

Restored from previous forum. Originally posted by wayne1.

see example below

Edited by - wayne1 on 05 October 2001 17:10:16
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Hi Wayne1,
sorry but this example is not working on my machine (W98SE). Neither as exe.
Can't set a new Clipboard text.

With the line:
MessageRequester("ClipBoard Text", peeks(hMem), 0)
I get always a old text.

Add this line:
MessageRequester("Needed Text", peeks(p), 0)
before the line:
MessageRequester("ClipBoard Text", peeks(hMem), 0)
and you will see that the Messagebox will be empty. (funny thing...)



Have a nice day...
Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by wayne1.

Yes I see, I was running win 2000 and it worked fine
I changed it and I tried it in win98FE and win 2000 it worked
and should work on all versions

See Code Below




Edited by - wayne1 on 05 October 2001 23:49:01
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by wayne1.

Code: Select all

;simple clipboard example
;This sample will copy to, then show the text in the clipboard
 
*Memory = AllocateMemory(3000)
OpenClipboard_(#Null);Handle to the window to be associated with the open clipboard.
;If this parameter is NULL, the open clipboard is associated with the current task.
EmptyClipboard_()
text$ = "This a test of copying to the clipboard";this string will be in the clipboard
PokeS(*Memory, text$)
SetClipboardData_(#CF_TEXT, *Memory)
h = GetClipboardData_(#CF_TEXT);text format
MessageRequester("ClipBoard Text", PeekS(h), 0)

CloseClipboard_()
;EmptyClipboard_();for reference
;The EmptyClipboard function empties the clipboard
;and frees handles to data in the clipboard.
;The function then assigns ownership of the clipboard
;to the window that currently has the clipboard open.
Edited by - wayne1 on 05 October 2001 23:45:41
Post Reply