How to toggle dcl_form_show / dcl_form_close?

Started by MiD-AwE, December 10, 2013, 10:16:17 AM

Previous topic - Next topic

MiD-AwE

 ???
Hi all,
I'm trying to add a ribbon button that will allow the user to toggle the appearance of a palette. The first time it's clicked the palette should be shown. Each time it is clicked after the first, it should toggle ( show / hide ) the palette. I would prefer that the palette be set to an Anchored Auto-hide state if possible, instead of closed, but I'll take what I can get.

Below is the code that I tried and it gives me an automation error. Undoubtedly, the error is because the  "DCL_FORM_ISVISIBLE" function returns an error if the form is not visible. <- that's as far as I get. What next?

Code (autolisp) Select
(DEFUN c:CNTRL ()
  (DCL_PROJECT_LOAD "CNTRL-PNL" T)
  (IF (DCL_FORM_ISVISIBLE CNTRL-PNL_CPL-CAD)
    (DCL_FORM_CLOSE CNTRL-PNL_CPL-CAD)
    (DCL_FORM_SHOW CNTRL-PNL_CPL-CAD)
  )
  (PRINC)
)


Thank you in advance for any help.

owenwengerd

It would be helpful if you could provide more precise information, such as the exact error message. Your code has some issues, but it should never produce an automation error. I suspect it is not an automation error at all, but let's clarify that before proceeding.

MiD-AwE

I must've had something else going wrong at the time.

I just tried it again and it says:

Application Error: 2 :- ADS request error

Does that sound right?

MiD-AwE

missed the OpenDCL Runtime Error. Now attached.

owenwengerd

I suspect that the 'No object instance' error is due to reloading your project every time. Try this:

Code (autolisp) Select

(DEFUN c:CNTRL ()
  (DCL_PROJECT_LOAD "CNTRL-PNL") ;do *not* reload every time
  (IF (DCL_FORM_ISACTIVE CNTRL-PNL_CPL-CAD)
    (DCL_FORM_CLOSE CNTRL-PNL_CPL-CAD)
    (DCL_FORM_SHOW CNTRL-PNL_CPL-CAD)
  )
  (PRINC)
)


MiD-AwE

Thank you Owen,

Unfortunately, I got the exact same error.  :-\

owenwengerd

Hmm, strange. Can you reproduce the problem with the _masterdemo sample form? Which CAD/OS versions are you testing on?

MiD-AwE


MiD-AwE

 :( I recieved two error messeges with the _MasterDemo_Main.

I also noticed that with the MasterDemo code it is not using DCL_FORM_ISVISIBLE, but instead utilizes DCL_FORM_ISACTIVE.

Any thoughts?

MiD-AwE

 8) Ok, I decided to change DCL_FORM_ISVISIBLE to DCL_FORM_ISACTIVE, and is works great.
Owen, I can't thank you enough.

owenwengerd

The code I posted earlier for you to try did use (dcl_Form_IsActive), but I forgot to mention that.