TheSwamp

Code Red => Visual DCL Programming => AutoLISP (Vanilla / Visual) => OpenDCL => Topic started by: Guest on May 02, 2007, 09:54:32 AM

Title: Finally getting my feet wet...Need help getting selected item in listbox
Post by: Guest on May 02, 2007, 09:54:32 AM
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)
Title: Re: Finally getting my feet wet...Need help getting selected item in listbox
Post by: Guest on May 02, 2007, 12:21:20 PM
And here's the ODC file I'm using.
Title: Re: Finally getting my feet wet...Need help getting selected item in listbox
Post by: jbuzbee on May 02, 2007, 03:35:05 PM
(Setq rValue (Odcl_ListBox_GetText
                 Toolbox_frmMain_lstUCSs
                 (Odcl_ListBox_GetCurSel Toolbox_frmMain_lstUCSs)))

Title: Re: Finally getting my feet wet...Need help getting selected item in listbox
Post by: Guest on May 02, 2007, 04:00:38 PM
Ahhhh.... I had both pieces but I didn't have them spliced together like what you'd posted.

Thanks!