Send PowerScript function
Description
Sends a message to a window so that it is executed immediately.
Syntax
1 |
<span>Send</span> ( <span>handle</span>, <span>message#</span>, <span>lowword</span>, <span>long</span> ) |
Argument |
Description |
---|---|
handle |
A long whose value is the system handle |
message# |
An UnsignedInteger whose value is the |
lowword |
A long whose value is the integer value |
long |
The long value of the message or a string. |
Return Values
Long. Returns the value returned by SendMessage in
Windows if it succeeds and -1 if an error occurs. If any argument’s
value is null, Send returns null.
Usage
PowerBuilder’s Send function sends
the message identified by message# and optionally, lowword and long,
to the window identified by handle to the Windows
function SendMessage. The message is sent directly
to the object, bypassing the object’s message queue. Send waits
until the message is processed and obtains the value returned by SendMessage.
Use the Handle function to get the Windows
handle of a PowerBuilder object.
You specify Windows messages by number. They are documented
in the file WINDOWS.H that is part of the Microsoft
Windows Software Development Kit (SDK) and other Windows development
tools.
Messages sent with Send are executed immediately.
To post a message to the end of an object’s message queue,
use the Post function.
Examples
This statement scrolls the window w_emp up
one page:
1 |
<span>Send</span>(Handle(w_emp), 277, 2, 0) |
Both of the following statements click the CommandButton cb_OK:
1 |
<span>Send</span>(Handle(Parent), 273, 0, Handle(cb_OK)) |
1 |
1 |
cb_OK.TriggerEvent(Clicked!) |
You can send messages to maximize or minimize a DataWindow,
and return it to normal. To use these messages, enable the TitleBar,
Minimize, and Maximize properties of your DataWindow control. Also,
you should give your DataWindow control an icon for its minimized
state.
This statement minimizes the DataWindow:
1 |
<span>Send</span>(Handle(dw_whatever), 274, 61472, 0) |
This statement maximizes the DataWindow:
1 |
<span>Send</span>(Handle(dw_whatever), 274, 61488, 0) |
This statement returns the DataWindow to its normal,
defined size:
1 |
<span>Send</span>(Handle(dw_whatever), 274, 61728, 0) |
You can send a Windows message to determine the last
item clicked in a multiselect ListBox. The following script for
the SelectionChanged event of a ListBox control gets the return
value of the LB_GETCURSEL message
which is the item number in the list (where the first item is 0,
not 1).
To get PowerBuilder’s index for the list item, the
example adds 1 to the return value from Send.
In this example, idx is an integer instance variable for the window:
1 |
// Send the Windows message for LB_GETCURSEL |
1 |
// to the list box |
1 |
idx = <span>Send</span>(Handle(This), 1033, 0, 0) |
1 |
idx = idx + 1 |