Author Topic: Finally getting my feet wet...Need help getting selected item in listbox  (Read 4038 times)

0 Members and 1 Guest are viewing this topic.

Guest

  • Guest
So I'm finally getting around to playing with OpenDCL and I've run into a little snag.  How do I get the selected item from a list box?  The code belows fills a listbox with the saved UCSs in the current drawing, but I can't figure out how to get the selected UCS's name from the list box after I double-click on it.

Code: [Select]
(DEFUN C:TOOLBOX (/ fn)
    (SETQ sVariable "Not set")
    ;;
    ;; Ensure the OpenDCL.##.ARX is loaded.
    (OR (VL-SYMBOL-VALUE 'ODCL_GETVERSIONEX)
        (AND (SETQ fn (FINDFILE "OpenDCL_ARXLoader.LSP"))
             (LOAD fn (STRCAT "Failed to load :- " fn))
        )
        (ALERT (STRCAT "Failed to load OpenDCL_ARXLoader.LSP"))
        (EXIT)
    )
    ;;
    ;; Ensure the Project ODC file is loaded.   
    (OR (ODCL_PROJECT_LOAD "Toolbox") (EXIT))
    ;;
    ;; Show the modal dialog .. (odcl_Form_IsActive test is not required
    ;;
    (ODCL_FORM_SHOW Toolbox_frmMain)
    (LoadUCSs)
    (PRINC)
)

(defun LoadUCSs ( / strUCSName strUCSList)
   (setq strUCSList (tnlist "UCS"))
   (Odcl_ListBox_Clear Toolbox_frmMain_lstUCSs)
   (Odcl_ListBox_AddList Toolbox_frmMain_lstUCSs strUCSList)
   (princ)
)

;;Michael Puckett
(defun tnlist (s / d r)
   (while (setq d (tblnext s (null d)))
      (setq r (cons (cdr (assoc 2 d)) r))
   )
   (reverse r)
)

(princ)

Guest

  • Guest
And here's the ODC file I'm using.

jbuzbee

  • Swamp Rat
  • Posts: 851
(Setq rValue (Odcl_ListBox_GetText
                 Toolbox_frmMain_lstUCSs
                 (Odcl_ListBox_GetCurSel Toolbox_frmMain_lstUCSs)))

James Buzbee
Windows 8

Guest

  • Guest
Ahhhh.... I had both pieces but I didn't have them spliced together like what you'd posted.

Thanks!