// ;|
// Author:   Roy Klein Gebbinck (www.b-k-g.nl)
// Made for: https://www.bricsys.com/common/support/forumthread.jsp?id=31606
//
// This is a 'mixed mode file': it contains DCL and LSP code.
// See: https://www.theswamp.org/index.php?topic=52289.msg572643#msg572643

BKG_FindToolbar : dialog {
  label = "BKG_FindToolbar";
  : text {value = "Move dialog + Select toolbar + Press OK";}
  : popup_list {key = "lst"; edit_width = 30; fixed_width = true;}
  ok_cancel;
}
/* |;

(defun c:BKG_FindToolbar ( / dcl fnm itm lst ret tlb)
  (if
    (and
      (setq fnm
        (vl-some
          '(lambda (str)
            (if (wcmatch (strcase str) "*BKG_FINDTOOLBAR*") str)
          )
          (reverse (vl-list-loaded-lisp))
        )
      )
      (setq dcl (load_dialog fnm))
    )
    (progn
      (setq lst
        (apply
          'append
          (mapcar
            '(lambda (mnu / mnuNme)
              (setq mnuNme (vla-get-name mnu))
              (mapcar
                '(lambda (tlb) (list mnuNme (vla-get-name tlb) tlb))
                (vle-collection->list (vla-get-toolbars mnu))
              )
            )
            (vle-collection->list (vla-get-menugroups (vlax-get-acad-object)))
          )
        )
      )
      (new_dialog "BKG_FindToolbar" dcl)
      (start_list "lst")
      (foreach sub lst (add_list (strcat (car sub) " -> " (cadr sub))))
      (end_list)
      (action_tile "accept" "(setq itm (get_tile \"lst\") pos (done_dialog 1))")
      (setq ret (start_dialog))
      (unload_dialog dcl)
      (if (= 1 ret)
        (progn
          (setq tlb (caddr (nth (atoi itm) lst)))
          (vla-put-visible tlb :vlax-true)
          (vla-float tlb (car pos) (cadr pos) 1)
        )
      )
    )
  )
  (princ)
)
