Date: 02-16-2022
Return to Index
created by gbSnippets
'The PowerBASIC Clipboard statement is used to get/set clipboard text.
'ClipBoard ReSet must be used before using any other ClipBoard statement
'Primary Code:
Clipboard Reset 'clear clipboard
Clipboard Get Text TO txt$ 'get text
Clipboard Set Text txt$ 'set text
'Compilable Example: (Jose Includes)
'This example copies text from a textbox and puts it on the clipboard
'It can also read whatever is on the clipboard and paste it in a 2nd textbox
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As DWord
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Put text on clipboard", 50,10,120,20
Control Add TextBox, hDlg, 200,"Sample Text", 50,40,120,20
Control Add Button, hDlg, 300,"Get text from clipboard", 50,70,120,20
Control Add TextBox, hDlg, 400,"", 50,100,120,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local temp$
If CB.Msg = %WM_Command AND CB.Ctl = 100 AND CB.Ctlmsg = %BN_Clicked Then
Control Get Text hDlg, 200 To temp$ 'get text from textbox
Clipboard Reset 'clear the clipboard so can place text there
Clipboard Set Text temp$ 'put text on clipboard
End If
If CB.Msg = %WM_Command AND CB.Ctl = 300 AND CB.Ctlmsg = %BN_Clicked Then
Clipboard Get Text temp$ 'put text on clipboard
Control Set Text hDlg, 400, temp$ 'get text from textbox
End If
End Function
'gbs_00081
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm