@taitrongsong hi,
check this fix, no change in dcl
in dcl (dialog control language) list tile, the first item is "0", most tiles values is in string
you can not use (get_tile) function until the dialog is really open at (start_dialog) call.
of course you can not call (get_tile) after the dialog is closed (done_dialog)
to save list default selection, you need to save the item index to some global variable or write it to registry.
in my example i use sysvar USERI1 (this one will be reset when you close the document)
enjoy
Moshe
(defun c:smp (/ get_media ctrl_selection_1 ctrl_accept ; local functions
dclfname dcl_id deviceList what_next media^ defSel)
(defun get_media (i lst / dev)
(setq dev (nth i lst))
(cdr (vl-registry-read (strcat "HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\control\\Print\\Printers\\" dev "\\DsDriver")"printMediaSupported"))
)
; callback
(defun ctrl_selections_1 (/ iSel lst)
(setq iSel (atoi (get_tile "selections_1")))
(setq lst (get_media iSel deviceList))
(start_list "selections_3")
(mapcar 'add_list lst)
(end_list)
(set_tile "selections_3" "0")
)
; callback
(defun ctrl_accept ()
; (print_1)
(setq defSel (setvar "useri1" (atoi (get_tile "selections_1"))))
(done_dialog 1)
)
(setq defSel (getvar "useri1"))
(if (and
(setq dclfname (findfile "Tip1756k.dcl")) ; get dcl file from supprt files search path
(setq dcl_id (load_dialog dclfname)) ; get dcl id
)
(progn
(setq deviceList (setq Path "\\System\\CurrentControlSet\\control\\Print\\" Printers (vl-registry-descendents (strcat "HKEY_LOCAL_MACHINE" Path "Printers"))))
(setq what_next 2)
(while (> what_next 1)
(if (not (new_dialog "FormPrinter" dcl_id "" '(-1 -1))) ; open dialog
(exit)
)
(start_list "selections_1")
(mapcar 'add_list deviceList)
(end_list)
(set_tile "selections_1" (itoa defSel))
(setq media^ (get_media defSel deviceList))
(start_list "selections_3")
(mapcar 'add_list media^)
(end_list)
(set_tile "selections_3" "0")
(action_tile "selections_1" "(ctrl_selections_1)")
; (setq KV (getvar "ctab"))
(action_tile "accept" "(ctrl_accept)")
(setq what_next (start_dialog))
); while
);progn
); if
(unload_dialog dcl_id)
(princ)
)