Image tree control

Started by Holon, January 16, 2009, 12:30:43 AM

Previous topic - Next topic

Holon

I have new dialog tree.odcl with modal dialogs Form into Form I have Image tree control  name "tree".
For an example I start LISP

(command "OPENDCL")
(DEFUN c:mytree (/ nCount)
  (dcl_Project_Load "tree" T)
  (dcl_FORM_SHOW tree_Form)
                 (dcl_TREE_ADDPARENT tree_Form_tree "slide1" "t1")
                 (dcl_TREE_ADDPARENT tree_Form_tree
                                      "slide library"
                                      "t2"
                 )
                 (dcl_TREE_ADDPARENT tree_Form_tree "slide3" "t3")
                 (dcl_TREE_ADDCHILD tree_Form_tree
                                     '(("t2" "Child1" "C1")
                                       ("t2" "Child2" "C2")
                                       ("t2" "Child3" "C3")
                                      )
                 )
                 (dcl_TREE_SELECTITEM tree_Form_tree "t1")
                 (dcl_TREE_COUNTITEMS tree_Form_tree)
        )

After start mytree on the screen of AutoCAD I see Form with Image tree control
but Image tree control empty, after closings form i have alert :
"An OpenDCL function argument processing exception has occurred!
Error: NIL value not allowed
Function: dcl_Tree_AddParent
Argument: 0 "
What do I do incorrectly?

BazzaCAD

you need to add an "Initialize" event to you form to populate the tree...

(defun c:tree_Form_OnInitialize (/)
                 (dcl_TREE_ADDPARENT tree_Form_tree "slide1" "t1")
                 (dcl_TREE_ADDPARENT tree_Form_tree
                                      "slide library"
                                      "t2"
                 )
                 (dcl_TREE_ADDPARENT tree_Form_tree "slide3" "t3")
                 (dcl_TREE_ADDCHILD tree_Form_tree
                                     '(("t2" "Child1" "C1")
                                       ("t2" "Child2" "C2")
                                       ("t2" "Child3" "C3")
                                      )
                 )
                 (dcl_TREE_SELECTITEM tree_Form_tree "t1")
                 (dcl_TREE_COUNTITEMS tree_Form_tree)
)
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

Holon

#2
Thanks! Now this code works
(command "OPENDCL")
(DEFUN c:mytree (/ )
  (dcl_Project_Load "tree" T)
  (dcl_FORM_SHOW tree_Form)
  (c:tree_Form_OnInitialize)
)
   
(defun c:tree_Form_OnInitialize (/)
                 (dcl_TREE_ADDPARENT tree_Form_tree "slide1" "t1")
                 (dcl_TREE_ADDPARENT tree_Form_tree
                                      "slide library"
                                      "t2"
                 )
                 (dcl_TREE_ADDPARENT tree_Form_tree "slide3" "t3")
                 (dcl_TREE_ADDCHILD tree_Form_tree
                                     '(("t2" "Child1" "C1")
                                       ("t2" "Child2" "C2")
                                       ("t2" "Child3" "C3")
                                      )
                 )
                 (dcl_TREE_SELECTITEM tree_Form_tree "t1")
                 (dcl_TREE_COUNTITEMS tree_Form_tree)
)

(defun c:tree_Form_tree_OnClicked (/)
  (dcl_MessageBox "MyTree: code must be added to event handler\r\nc:tree_Form_tree_OnClicked" "MyTree")
)


But there was a question how to receive correct inquiry after Click on a tree controle.
Now I have only one function c:tree_Form_tree_OnClicked, for all CHILDS, and it would be necessary to me that at concrete to a clique concrete function was caused. How it to make?

Fred Tomke

Hi, Holon, if I understood you right, you want to get the item you clicked on. If so, then do:


(defun c:tree_Form_tree_OnClicked (/)
  (if (and (setq strKey (dcl_Tree_GetSelectedItem tree_Form_tree))
           (= (type strKey) 'STR)) ;; make sure that the result is a key (only if you use strings as keys)
    (princ (strcat "\nYou've selected " (dcl_tree_getitemtext tree_Form_tree strKey) "\r"))
  ); if
); c:tree_Form_tree_OnClicked


Hope, that helps.

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

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

Holon