ObjectDCL Banner

Form_Close Method

Description

This method will close the indicated dialog.

Parameters

MyDialogReference
Reference to the dialog.
ProjectFile
String identifying the project as it was passed in LoadProject.
DialogName
String identifying the dialog by name.

Return Values

Returns the following according to the situation:

  • T when successful.
  • Nil if the form is not found or the form does not support the operation.

AutoLISP Syntax

The recommended convention is passing the control identifier directly:

CopyCode imageCopy Code
(Odcl_Form_Close 
		MyDialogReference [as Reference])

An alternative convention is to identify the control by providing the project file, the dialog name and the control name:

CopyCode imageCopy Code
(Odcl_Form_Close
		ProjectFile [as String]
		DialogName [as String]
		ControlName [as String])

Remarks

This function must be the last function called in an event defun. Any functions called from within the event defun after this function may not work correctly. The reason is because the dialog box is not completely closed until the event defun is completed. Many va, vla, vlax and command function calls may not work from the event defun.   The correct way to call these functions is to call them after the Form_Close function is completed.

See the example below on how to correctly handle this situation.

Applies For

Dockable, FileDialog, Modal, Modeless.

Example

This example relates to the remark above.

CopyCode imageCopy Code
(defun c:show (/ bOkPressed)
	; set the flag to nil
	(setq bOkPressed Nil)

	; here is the event defun that is to closes the dialog box. 
	(defun c:dialog_OK_OnClicked ()
		; set the flag as true so our completion code will be activated. 
		(setq bOkPressed T)

		; now close the dialog box 
		(odcl_form_close project_dialog)
	)

	; here is the event defun that cancels the dialog box 
	(defun c:dialog_Cancel_OnClicked ()
		; set the flag as nil so our completion code 
		; will NOT be activated. 
		(setq bOkPressed Nil)

		; now close the dialog box 
		(odcl_form_close project_dialog)
	)

	; load the project if not already loaded. 
	(odcl_loadproject "project")

	; show the dialog box. 
	(odcl_form_show project_dialog)

	; if the OK button was pressed. 
	(if (= bOkPressed T)
		; now lets do completion code, 
		; (in this case a simple command call) 
		(command "line" (list 0 0) (list 10 10) "")
	)
)

See Also

Form_CloseAll, Form_Enable, Form_IsActive, Form_Show