DIALOG SEND statement

Purpose

Send a message to a dialog, then wait until the message has been processed before continuing.

Syntax

DIALOG SEND hDlg, msg&, wParam&, lParam& [TO lResult&]

Remarks

hDlg identifies the dialog which should receive the message specified by msg&. wParam& is the first message parameter, and lParam& is the second message parameter.

By default, PowerBASIC passes these parameters BYVAL. If the target dialog is expected to return or alter the values passed in the wParam& and lParam& parameters, pass them using VARPTR() or the return values will be discarded. For example:

DIALOG SEND CBHNDL, %WM_USER, VARPTR(Param1&), VARPTR(Param2&)

TO 

The return value may be returned and stored in the variable lResult& after the message was processed by the dialog.

Restrictions 

If the target dialog was not created by the same thread, the DIALOG SEND statement becomes blocked until the thread processes the message. The InSendMessage API function will return TRUE (non-zero) if the callback code is currently processing a message from a separate thread.

To send a custom message to a dialog, use a message value in the range of (%WM_USER + 500) to (%WM_USER + &H07FFF), or use the RegisterWindowMessage API to obtain a unique message value from the operating system.

A dialog callback can send a message to its own dialog, but care should be taken not to create an infinite loop. Also, if DIALOG SEND sends a message that arrives back in the same callback as the message originated, care should be exercised to ensure that critical STATIC and GLOBAL variables are not unexpectedly altered by the second message processing code in the callback. This is known as re-entrant code design.

See also

Dynamic Dialog Tools, CONTROL SEND