Check if a form is loaded and visible

Started by Emiliano, May 04, 2012, 05:48:32 AM

Previous topic - Next topic

Emiliano

Hello,
how can I check whether a certain form is loaded and visible?

I tried

(dcl_Form_IsVisible NomeApp_FormP)

but does not work if the project is not loaded
Do you have any suggestions?

roy_043

Perhaps this:
Code (autolisp) Select
(and
  (dcl_Form_IsActive NomeApp_NomeForm)
  (dcl_Form_IsVisible NomeApp_NomeForm)
)


From the explanation in the Help you would expect that just (dcl_Form_IsVisible NomeApp_NomeForm) would be enough. But somehow that is not the case.

owenwengerd

The (dcl_form_IsVisible) function is enough, but you can't pass a NIL argument. This should work though:
Code (autolisp) Select
(and NomeApp_NomeForm (dcl_Form_IsVisible NomeApp_NomeForm))
Owen Wengerd (Outside The Box) / ManuSoft

Emiliano

Hello,
thanks for the answer.
Unfortunately now I can not verify.
But I think your solution does not work when the project Nome.odcl is not loaded in the file.

roy_043

Quote from: owenwengerd on May 04, 2012, 08:08:34 AM
The (dcl_form_IsVisible) function is enough, but you can't pass a NIL argument. This should work though:
Code (autolisp) Select
(and NomeApp_NomeForm (dcl_Form_IsVisible NomeApp_NomeForm))

Somehow that does not work.

Test:

Files:
NomeApp.lsp
NomeApp.odcl
From: http://www.opendcl.com/forum/index.php?topic=1790.msg8820#msg8820

1. Load and start the lisp.
2. Close the form.
3. !NomeApp_NomeForm => <Entity name: #>
4. (and NomeApp_NomeForm (dcl_Form_IsVisible NomeApp_NomeForm)) => No object instance error.

Bricscad 12.2.4 Beta + ODCL 7.0.0.4
Bricscad 11.4.6 + ODCL 7.0.0.4

owenwengerd

You are correct, I forgot that the form symbol has a value as long as the project is loaded.
Owen Wengerd (Outside The Box) / ManuSoft

Fred Tomke

Hi, I want to add that dcl_form_isactive will go on returning T if a none-modal form is being hidden by calling dcl_form_hide. That's why dcl_form_isvisible exists.
You should avoid calling dcl_form_show if dcl_form_isactive is returning T because no form could be shown twice (even one of them is invisible).
For modeless forms you should check it this way:

Code (autolisp) Select

(cond
  ((not myproj_mymodeless)
   (dcl_project_load "myproj")
   (dcl_form_show myproj_mymodeless))
  ((not (dcl_form_isactive myproj_mymodeless))
   (dcl_form_show myproj_mymodeless))
  ((not (dcl_form_isvisible myproj_mymodeless))
   (dcl_form_hide myproj_mymodeless nil))
);cond


Regards,
Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Emiliano

Thanks to all for their valuable advice.
I solved the problem by modifying the application's workflow.
But these suggestions will certainly help in the future.

thanks