Check if a form is loaded and visible

Started by Emiliano · 2012-05-04 12:48 UTC · 7 replies · SMF topic #1797

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?
Perhaps this:
(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.
The (dcl_form_IsVisible) function is enough, but you can't pass a NIL argument. This should work though:
(and NomeApp_NomeForm (dcl_Form_IsVisible NomeApp_NomeForm))
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.
author=owenwengerd link=topic=1797.msg8853#msg8853 date=1336144114 wrote:
The (dcl_form_IsVisible) function is enough, but you can't pass a NIL argument. This should work though:
(and NomeApp_NomeForm (dcl_Form_IsVisible NomeApp_NomeForm))


Somehow that does not work.

Test:

Files:
NomeApp.lsp
NomeApp.odcl
From: {2}

1. Load and start the lisp.
2. Close the form.
3. !NomeApp_NomeForm =>
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
You are correct, I forgot that the form symbol has a value as long as the project is loaded.
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:


(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
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