Clipboard, copy, paste

Syntax

s.getclip([format])
s.setclip([format])
s.getsel([cut] [format] [control])
s.setsel([format] [control])

 

Parts

s - str variable.

format - clipboard format. Integer (for predefined formats) or string (for registered formats). Default or 0: uses CF_UNICODETEXT and converts to/from Unicode UTF-16.

cut - if nonzero, use Ctrl+X (cut). Default or 0: use Ctrl+C (copy).

control - handle of control to work with. Default or 0: the focused control.

 

Remarks

getclip stores the clipboard text to s.

setclip copies s to the clipboard.

getsel copies the currently selected text to s.

setsel pastes s (s.setsel without format is the same as outp s).

 

All these functions use the clipboard. After getsel and setsel, QM restores previous clipboard content (text only), unless run-time option opt clip 1 is set.

 

To empty the clipboard, use setclip with empty string:

 

str s.setclip

 

or

 

s.all; s.setclip

 

In Unicode mode these functions automatically support Unicode text. Don't use CF_UNICODETEXT format, unless you work with UTF-16.

 

str variables can store text or binary data. These functions recognize clipboard formats CF_TEXT, CF_OEMTEXT, CF_UNICODETEXT and CF_BITMAP. Data of other formats is transfered to/from the clipboard without processing. Also can be used registered formats (format must be format name, or numeric value returned by RegisterClipboardFormat).

 

If format is CF_BITMAP, s must be picture file path. Instead of using s to store clipboard data, is used that file:

getclip saves the clipboard data to file s. File must be bmp.

setclip copies file s to the clipboard. File must be bmp, jpg or gif.

getsel saves the currently selected data to file s. File must be bmp.

setsel pastes file s. File must be bmp, jpg or gif.

 

Functions getsel and setsel, if control is omitted or 0, use keys (Ctrl+C, Ctrl+X, Ctrl+V) to copy/cut/paste. If control is child window handle, these functions instead send messages (WM_COPY, etc) to it. These messages are supported by most edit and rich edit controls. Messages can be sent even to controls in inactive windows.

 

Examples

str s1 = "string1"
str s2
s1.setclip
s2.getclip
 now s2 is "string1"

str s.getfile("unicodefile")
s.setsel(CF_UNICODETEXT)

str ss="$My Pictures$\test.bmp"
ss.setclip(CF_BITMAP)

str s.getclip("HTML Format")