DIALOG END statement

Purpose | Close and destroy the specified dialog.
Syntax | DIALOG END hDlg [, lResult&]
Remarks | The dialog specified by the hDlg variable is destroyed. lResult& optionally specifies a value to return to the DIALOG SHOW MODAL or DIALOG SHOW MODELESS statement that activated the dialog initially.

Restrictions

DIALOG END cannot close or destroy a dialog in a separate thread. In this case, send or post a message to the dialog to signal it to close, and respond to the message in the callback for the specified dialog. For example:

' Trigger a DIALOG END in a separate thread

DIALOG SEND hDlg, %WM_SYSCOMMAND, %SC_CLOSE, 0

DIALOG END cannot be used during processing of the %WM_INITDIALOG message. If this effect is necessary, the solution is to post a user-defined message to the dialog and use DIALOG END at that point. For example:

CALLBACK FUNCTION MyDialogCallback

SELECT CASE CB.MSG

CASE %WM_INITDIALOG

IF gMustEnd& THEN _ ' We have to stop!

DIALOG POST CB.HNDL, %WM_USER+999&, 0, 0

CASE %WM_USER + 999&

DIALOG END CB.HNDL

FUNCTION = 1

END SELECT

END FUNCTION

See also | Dynamic Dialog Tools, DIALOG NEW, DIALOG SHOW MODELESS, THREAD CREATE