OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: JEdwardL on January 29, 2013, 09:58:47 AM

Title: Controlling ZOrder and
Post by: JEdwardL on January 29, 2013, 09:58:47 AM
I'm can't seem to control the ZOrder properly.  Is there a way to move to a particular control using ZOrder and then continuing seqentially from there?  I have several text boxes that are being populated programmatically, but I need a way to continue in the dialog from the point where the program leaves off in order to populate the remaining boxes.

Thank you,

J Leavitt
Title: Re: Controlling ZOrder and
Post by: roy_043 on January 29, 2013, 10:44:54 AM
You can use (dcl_Control_SetFocus control) to set the focus to the text box following the last one that was filled programmatically. The ZOrder will control the sequence from that point.
Title: Re: Controlling ZOrder and
Post by: JEdwardL on January 29, 2013, 10:49:08 AM
If I'm not mistaken, I can't use SetFocus within an Initialize event.  Has that restriction been removed?

Thank you,

J Leavitt
Title: Re: Controlling ZOrder and
Post by: roy_043 on January 29, 2013, 02:38:47 PM
You are completely right. So it is not as easy as I had hoped. But manipulating the ZOrder does work. However, if you do not also change the ZOrder of the controls before the first text box, the result will be confusing if the user wants to cycle through the form again.

Code (autolisp) Select

(defun c:TextBoxTest ( / c:TextBoxTest_Form1_OnInitialize stringList)

  (defun c:TextBoxTest_Form1_OnInitialize ()
    (foreach
      control
      (list ; Controls before first TextBox.
        TextBoxTest_Form1_TextButton0
        TextBoxTest_Form1_TextButton1
      )
      (dcl_Control_ZOrder control 0)
    )
    (mapcar
      '(lambda (index string / control)
        (setq control (eval (read (strcat "TextBoxTest_Form1_TextBox" (itoa index)))))
        (dcl_Control_SetText control string)
        (dcl_Control_ZOrder control 0)
      )
      '(0 1 2 3 4 5)
      stringList
    )
  )

  (setvar 'cmdecho 0)
  (command "OPENDCL")
  (setvar 'cmdecho 1)

  (setq stringList '("A" "B" "C"))
  (dcl_Project_Load "TextBoxTest" T)
  (dcl_Form_Show TextBoxTest_Form1)
)
Title: Re: Controlling ZOrder and
Post by: owenwengerd on January 29, 2013, 04:41:22 PM
Another idea is to disable the ones you want to skip.
Title: Re: Controlling ZOrder and
Post by: roy_043 on January 30, 2013, 05:27:12 AM
@ Owen:
Just wondering: is there a way to retrieve the ZOrder of a form?
Title: Re: Controlling ZOrder and
Post by: owenwengerd on January 30, 2013, 08:31:42 AM
Quote from: roy_043 on January 30, 2013, 05:27:12 AM
Just wondering: is there a way to retrieve the ZOrder of a form?

I don't believe so, unless there's some way to do it using standar Windows functionality via COM.
Title: Re: Controlling ZOrder and
Post by: JEdwardL on January 30, 2013, 08:48:36 AM
Thank you both!

I managed to adapt the sample code that roy_043 posted and it works fine, although it would be ever so much easier to be able to specify the order programatically.