Functions for Hiding Dialog Boxes
 
 
 

A user cannot make an interactive selection while a dialog box is active. If you want the user to make a selection from the graphics screen, you must hide your dialog box and then restore it. Hiding the box is the same as ending it with done_dialog, except your callback function must use the done_dialog status argument to indicate that the dialog box is hidden—as opposed to ended or canceled. Set status to an application-defined value.

The start_dialog function returns the application-defined status when the dialog box disappears. Your program must then examine the status returned by start_dialog and determine what to do next. For standard and application-defined status values, see in the AutoLISP Reference.

For example, here is a simple dialog box that may require a user to pick a point in the AutoCAD graphics window:

The dialog box is defined with the following DCL:

hidedcl : dialog
{ label="Hide Example";
  : column
  { : text
	{ key="message";
	label="Click PickMe to pick a point";
	fixed_width=true;
	fixed_height=true;
	alignment=centered;
}
	:row
	{ ok_only;
	:retirement_button
	{ label	= "PickMe";
		key	= "hide";
		mnemonic = "H";
}}}}

The function controlling the dialog box displays the window until the user presses OK or closes the window. If the user chooses PickMe, the code hides the dialog box and prompts the user to select a point. The following AutoLISP code controls the dialog box:

(defun c:hidedcl (/ dcl_id what_next cnt)
  (setq dcl_id (load_dialog "hidedcl.dcl"))  ;Load the dialog box.
  (setq what_next 2)
  (setq cnt 1)
  (while (>= what_next 2)					;Begin display loop.
	(if (null (new_dialog "hidedcl" dcl_id)) ;Initialize dialog
	(exit)								 ;box, exit if nil
	); endif								 ;returned.


	; Set action to take if a button is pressed. Either button 
	; results in a done_dialog call to close the dialog box.
	; Each button associates a specific status code with 
	; done_dialog, and this status code is returned by 
	; start_dialog. 


	(action_tile "accept" "(done_dialog 1)") ;Set action for OK.
	(action_tile "hide" "(done_dialog 4)")   ;Set action for 
											 ;PickMe.
	(setq what_next (start_dialog))		;Display dialog box.
	; 
	(cond
	((= what_next 4)					 ;Prompt user to
		(getpoint "\npick a point")		;pick pt.
	)
	((= what_next 0)
		(prompt "\nuser cancelled dialog")
	)
	)
  )
  (unload_dialog dcl_id)
  (princ)
)
NoteThe term_dialog function terminates all dialog boxes at once but does not return a status code, so there is no way for an application to distinguish between hiding a nested box and canceling boxes due to an error condition.