Question
Hi I am closing a Modal dialog box using Odcl_Form_Close, then calling Odcl_Form_IsActive right after. The problem is that Odcl_Form_IsActive is telling me the dialog box I am closing is still active. Why?
Answer
The problem is you are calling Odcl_Form_IsActive from the same event defun Odcl_Form_Close is being called from. The dialog box is hidden from the user when the Odcl_Form_Close is called, but is truely not destroyed in memory until after the function Odcl_Form_Show is completed in the main sequence of code. The solution is to call Odcl_Form_IsActive and all the associated code after it from within the main defun sequence. This will cause Odcl_Form_IsActive to tell you the Modal dialog box is now closed.
Example Error Code:
(defun c:test () (Odcl_LoadProject "testproject") (Odcl_Form_Show testproject_dialogA) ) (defun c:testproject_dialogA_button1_OnClicked() (Odcl_Form_Close testproject_dialogA) (if (Odcl_Form_IsActive testproject_dialogA) (progn (Alert "Dialog box is still active") ; do more stuff here ) ) )
Corrected Example Code:
(defun c:test () (Odcl_LoadProject "testproject") (setq buttonPressed nil) (Odcl_Form_Show testproject_dialogA) (if (= buttonPressed "button1") (if (Odcl_Form_IsActive testproject_dialogA) (progn (Alert "Dialog box is still active") ; do more stuff here ) ) ) ) (defun c:testproject_dialogA_button1_OnClicked() (setq buttonPressed "button1") (Odcl_Form_Close testproject_dialogA) ) )
Knowledge Base
FAQ