this is hopefully a working version of your files treeview:
Code:

dialog switchbar {
  option dbu
  size -1 -1 110 110
  list 2, 5 5 100 105
  list 3, 5 5 100 105, hide
}
 
on *:dialog:switchbar:init:0:{
  ;
  ; edit here
  ;
  dll $mdx SetMircVersion $version
  dll $mdx MarkDialog $dname
  dll $mdx SetControlMDX 2 TreeView hasbuttons > dll\mdx\views.mdx
  ;
  ; root folder 
  ;
  var %root = $mircdir
  window -hls @f
  var %files = $findfile(%root,*,0,@f), %dirs = $finddir(%root,*,0,@f)
 
  did -i switchbar 2 1 cb root
  did -a switchbar 2 +eb Folder $gettok(%root,-1,92) has %files files in %dirs subdirs.
  did -i switchbar 2 1 cb last
  did -a switchbar 2 +b $gettok(%root,-1,92)
  did -i switchbar 2 1 cb last
 
  var %i = 1
  while $line(@f,%i) {
    var %line = $ifmatch, %nopath = $nopath(%line)
 
    var %count = $count(%line,\), %prev_count = $count($line(@f,$calc(%i - 1)),\)
    while %count < %prev_count {
      did -i switchbar 2 1 cb up
      inc %count
    }
 
    if $isdir(%line) {
      did -a switchbar 2 +b %nopath
      if %line isin $line(@f,$calc(%i + 1)) {
        did -i switchbar 2 1 cb last
      }
    }
    else {
      did -a switchbar 2 %nopath
    }
    inc %i
  }
  window -c @f
}

If you have further questions about mdx, I think mircscripts's experts can be more helpful.