s.getclip([format]) s.setclip([format]) s.getsel([cut] [format] [control]) s.setsel([format] [control])
s - str variable.
format - clipboard format. Integer (for predefined formats) or string (for registered formats). Default or 0: text.
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.
getclip copies clipboard data to s. It is text, unless other format specified.
setclip copies s to the clipboard.
getsel copies selected text to s.
setsel pastes s. If format and control not used, it is the same as paste (paste 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.
For setsel, the speed depends on spe.
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 s contains UTF-16 text. QM text format is UTF-8 (in Unicode mode) or ANSI.
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; then format must be format name (eg "HTML Format"), 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 clipboard data to file s. File must be bmp.
setclip copies file s to the clipboard. File can be bmp, jpg or gif. QM 2.3.4: also can be png.
getsel saves selected picture to file s. File must be bmp.
setsel pastes file s. File can be bmp, jpg or gif. QM 2.3.4: also can be png.
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 a 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.
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")