what does dcl_Form_IsActive really do?

Started by jmaeding, April 19, 2010, 11:36:36 AM

Previous topic - Next topic

jmaeding

I use this function all over the place to test if a modeless status form is "open", so I can close it.
But is that testing if the form's variable is nil, or is it testing if the form is shown?
I am really only interested in closing a form that is shown of course.
Is IsVisible better?  How about IsEnabled?
I was sloppy in the past on this, but now need to know.

I am partially asking because of the thing where current version of ODCL does not allow:
(dcl_form_IsActive myform) if myform is nil.
I can test if something is nil without the dcl_form_IsActive function, so what is it for exactly?
thanks

Fred Tomke

Hi, jmaeding

QuoteBut is that testing if the form's variable is nil, or is it testing if the form is shown?
No, you have to test the variable by your own.
Code (autolisp) Select
(if (and MyProj_MyForm (dcl_form_isactive MyProj_MyForm))
 (do_something_in_the_form)
); if


The variable is nil as long as the project wasn't loaded before.

IsActive will return T, if the form was shown before (using Show-method) and was not closed yet (using Close-method).
IsVisible will return T, if the active form is not Hidden (using Hide-method).
IsEnabled will return T, if the active form is not Disabled (using Enable-method).

Fred

Fred Tomke
Dipl.-Ing. (FH) Landespflege

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

jmaeding

not sure I get this.
what are the pratical results of that?
It seems like we should use IsActive for modal forms, and IsVisible for modeless then, right?
I will put the code to test if the project is loaded in another central place, no need spraying out that test into all the code.

jmaeding

I'm not convinced IsVisible is useful.
You would not use it on modals, as hiding those is a no-no (right?).
For a modeless, if the form was closed with close method, the IsVisible errors out, but IsActive does not and tells you what you need "is the form showing or not".
You would therefore not use IsVisible on a modeless either, IsActive tells you all that is needed.

I get the feeling it used to be that hiding a form did not make it "inactive" but now it does.
I saw a post where Owen mentioned the form_hide now does close a form, so this seems backed up.
Am I missing some useful functionality of IsVisible here?
I want my code to be as simple and correct as possible, thx for the comments

Fred Tomke

Hi, jmaeding,

no: If a modeless form is active it does not mean that it is visible. You can hide a modeless form meanwhile the user picks a point in the drawing and after that make the form visible without the need of initializing the form again. You can only hide a form if the form was instanced.

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

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

Fred Tomke

Quote from: jmaeding on April 19, 2010, 01:14:54 PM
You would not use it on modals, as hiding those is a no-no (right?).

Right, since the user can only get access to the commandline if the modal form's instance was removed from the memory (using close method), the hide method does only make sense if you leave a small control bar on the screen to make the hidden modal form visible again (to show a contruction result, for instance).

IsActive does only mean that the form was instanced and the control's variables are set (they are not if the form is not activated).
When s symbol with the form's varname is set with an entity it only means that the project was loaded but it does not mean that it was instanced. That does IsActive for you. An active form must not be visible at least - that does IsVisible.

I use all these 3 different queries of states of modeless forms and it's very important that they exist. These three have completely different meanings.

Hope that I could light the dark :)

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

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

owenwengerd

The only possible reason to call IsActive is if something besides OpenDCL is changing the values of the lisp symbols (therby causing them to not be synchronized with the lifetime of the form instance). If nothing else is changing their values, you can simply check whether the value of the symbol is NIL and get the same result as you'll get by calling IsActive.
Owen Wengerd (Outside The Box) / ManuSoft

jmaeding

Thx for replies,
I think I see my pattern of use now, and why IsVisible is not needed for me.
For modeless dialogs that act as "status" or "progress" forms, I always use close method on them.
So no messing with IsVisible for those, must use IsActive to test if they are showing.
For my other modeless dialogs, I do hide them and unhide.  I test to see if they are instantiated or not with IsActive, then unhide or show new.
I am not seeing the case where IsActive gives a True result when the form is hidden with hide method and param of 1.  IsActive gives a nil in that case.

I did not follow Owen's comment that testing the var for nil is same as IsActive.  If you open a blank drawing, load a project and test for var, its there (as an ename...).  For a modeless, you must check the IsActive return before hoping to try the IsVisible test.  What I have found is stopping at IsActive works fine, no disadvantages.

pls correct my reasoning as needed, just trying to spill my thoughts for sorting out, thx

jmaeding

I lied, tests just now show IsActive does give the True return for hidden forms, sorry.

I see now that you can access a form hidden with hide method.  That is why I never got caught by not checking if a hidden form was visible.  The update works either way.

You do get caught if a form is not active though, that will cause things to error out.
My sloppiness worked so I never paid attention.  I think I got it now. thx



owenwengerd

Quote from: jmaeding on April 19, 2010, 02:49:16 PM
I did not follow Owen's comment that testing the var for nil is same as IsActive.

You're right, for forms the variable is set when the project is loaded. I was thinking about controls; for controls the variable is only set while the form is active.
Owen Wengerd (Outside The Box) / ManuSoft