background image
<< Custom Objects - Supporting custom text fields | Custom Objects - Windows style bits >>
Custom Objects - Using Clipboard methods
<< Custom Objects - Supporting custom text fields | Custom Objects - Windows style bits >>
324
User's Guide
17 S
UPPORTING
C
USTOM
O
BJECTS
Supporting nongraphical controls
LIST OF STRING GetMultiText ()
Clipboard.SetText () // Clear the clipboard
TypeKeys ("<Ctrl-Home>")
TypeKeys ("<Ctrl-Shift-End>")
TypeKeys ("<Ctrl-Insert>")
TypeKeys ("<Left>")
return (Clipboard.GetText ())
Using Clipboard
methods
If you are having trouble getting or setting information with a custom object
that contains text, you might want to try the 4Test Clipboard methods. For
example, assume you have a class, CustomTextBuffer, which is similar to a
TextField, but using the TextField's GetText and SetText methods do not
work with the CustomTextBuffer. You can use the ClipboardClass GetText
and SetText methods as follows.
Getting text The following sample code retrieves the contents of the
CustomTextBuffer by placing it on the Clipboard, then printing the Clipboard
contents:
// Go to beginning of text field
CustomTextBuffer.TypeKeys ("<Ctrl-Home>")
// Highlight it
CustomTextBuffer.TypeKeys ("<Ctrl-Shift-End>")
// Copy it to the Clipboard
CustomTextBuffer.TypeKeys ("<Ctrl-Insert>")
// Print the contents of the Clipboard
Print (Clipboard.GetText())
Setting text Similarly, the following sample code inserts text into the custom
object by pasting it from the Clipboard:
// Go to beginning of text field
CustomTextBuffer.TypeKeys ("<Ctrl-Home>")
// Highlight it
CustomTextBuffer.TypeKeys ("<Ctrl-Shift-End>")
// Paste the Clipboard contents into the text field
CustomTextBuffer.TypeKeys ("<Shift-Insert>")
Tip You can wrap this functionality in GetText and SetText methods
you define for your custom class, similar to what was shown in
"Supporting custom text fields" on page 323.
Supporting custom
list boxes
To support custom list boxes, you can write "low-level" methods as
demonstrated in the previous section.
A second approach is to implement the necessary Microsoft Windows
messages and set the necessary Windows style bits so that you can use the
standard list box methods on your custom list box. The Microsoft Windows
messages which you must implement are: