dialog cdplayer {
  title "CD Player for mIRC v1.10 (c) 1999 DragonZap"
  size -1 -1 400 200

  box "Info traccia",49, 5 5 190 145
  text "Traccia:",50,10 25 35 20
  combo 51,45 25 50 200,drop
  text "di 0",52,100 25 50 20
  text "Lunghezza:",54,10 55 70 20
  text "",55,135 55 50 20,right
  text "Posizione:",56,10 75 70 20
  text "",57,135 75 50 20,right
  text "Rimasta:",58,10 95 80 20
  text "",59,135 95 50 20,right
  text "Inizio:",60,10 115 80 20
  text "",61,135 115 50 20,right


  box "CD info",99,205 5 190 145
  text "Lunghezza:",100,210 55 70 20
  text "",101,335 55 50 20,right
  text "Posizione:",102,210 75 70 20
  text "",103,335 75 50 20,right
  text "Rimasto:",104,210 95 70 20
  text "",105,335 95 50 20,right
  button "Apri &Mixer",106,260 25 70 20

  button "Espelli",1,5 155 50 20,disable
  button "Retrarre",2,60 155 50 20,disable
  button "Stop",3,115 155 50 20,disable
  button "Play",4,170 155 50 20,ok disable
  button "Pause",5,225 155 50 20,disable
  button "< Traccia",6,280 155 50 20,disable
  button "Traccia >",7,335 155 50 20,disable

  button "",499,0 0 1 1,hide cancel
  edit "",500,0 180 400 20,read
}

;Mixer dialog
dialog mixer {
  title "Little mIRC Mixer"
  size -1 -1 300 115

  button "",500,1 1 50 50,cancel hide
  box "Audio",2,5 0 190 60
  radio "",3,10 15 20 20,group
  radio "",4,10 35 20 20
  text "Source lines",30,30 15 100 20,group
  text "Destination lines",40,30 35 100 20

  text "Audio line:",11,5 65 75 20
  combo 5,80 65 215 150,drop
  text "Line control:",12,5 90 75 20
  combo 6,80 90 215 150,drop

  text "Min:",7,205 5 90 20,hide
  text "Value:" ,8,205 25 35 20,hide
  edit "",9,240 25 55 20,hide
  text "Max:",10,205 45 90 20,hide

  check "",13,205 5 20 20, hide
  text "Enabled",130,225 5 90 20, hide
}
alias cdplayer {
  if ( $dialog(dz.cdplayer) ) dialog -v dz.cdplayer
  else dialog -md dz.cdplayer cdplayer 
  if ( %cc181p == on ) { $tunder TDDialog $dialog(dz.cdplayer).hwnd > 2 }
}
alias -l set-caps {
  set %captype $mci( capability [ $da ] device type )
  ;Detect the CD player's capabilities and adjust enables/disables accordingly
  if ( $gettok( %captype ,1,32 ) == OK ) {
    if ( $gettok(%captype,2,32) != cdaudio ) {
      did -b dz.cdplayer 1,2,3,4,5,6,7
      return
    }
  }
  else {
    if ( $gettok( %captype ,2,32) == MMSYSTEM263 ) mci open cdaudio alias $da
    return
  }
  did $iif( $mciok( capability [ $da ] can eject ) == true ,-e,-b) dz.cdplayer 1,2
  did -o dz.cdplayer 5 1 $iif( ( $mciok( status [ $da ] mode ) == stopped ) && ( %dz.cdplayer.pauseinfo != $null ), Unpause, Pause)
  set-track-info
}
alias -l set-track-info {
  var %tmax, %tc, %auditrak, %ctrak, %cdpos, %trakpos
  ;Never check the number of tracks if there's no CD in the drive, or the program will freeze up
  if (( $mciok( capability [ $da ] device type ) != cdaudio ) || ( $mciok( status [ $da ] mode ) == open ) || ( $mciok( capability [ $da ] can play ) != true )) {
    did -b dz.cdplayer 3,4,5,6,7
    did -r dz.cdplayer 51
    did -o dz.cdplayer 55,57,59,61,101,103,105,500 1
    did -o dz.cdplayer 52 1 of
    unset %dz.cdplayer.ctrack
    return
  }
  if ( %dz.cdplayer.ctrack == $null ) {
    did -r dz.cdplayer 51
    set %tmax $mciok( status [ $da ] number of tracks )
    did -o dz.cdplayer 52 1 of %tmax
    set %tc 0
    set %auditrak 0
    :trackscan
    inc %tc
    if ( %tc > %tmax ) goto trackdone
    if ( $mciok( status [ $da ] type track [ %tc ] ) == audio ) {
      did -a dz.cdplayer 51 %tc
      set %auditrak 1
    }
    else did -a dz.cdplayer 51 ( $+ %tc $+ )
    goto trackscan
    :trackdone
    if ( %auditrak != 1 ) {
      did -o dz.cdplayer 500 1 No audio tracks were found on the CD.
      did -b dz.cdplayer 3,4,5,6,7
      did -o dz.cdplayer 55,57,59,101,103,105 1
      return
    }
    did -o dz.cdplayer 500 1
    mci set $da time format ms
    did -o dz.cdplayer 101 1 $hms($mciok(status [ $da ] length ))
    did -e dz.cdplayer 3,4,5,6,7
  }
  set %ctrak $mciok( status [ $da ] current track )
  mci set $da time format ms
  if ( %dz.cdplayer.ctrack != %ctrak ) {
    did -c dz.cdplayer 51 %ctrak
    did -o dz.cdplayer 55 1 $hms($mciok(status [ $da ] length track [ %ctrak ] ))
    did -o dz.cdplayer 61 1 $hms($mciok(status [ $da ] position track [ %ctrak ] ))
  }
  set %cdpos $mciok(status [ $da ] position )
  set %trakpos $calc( %cdpos - $mciok(status [ $da ] position track [ %ctrak ] ))
  did -o dz.cdplayer 57 1 $hms(%trakpos)
  did -o dz.cdplayer 59 1 $hms($calc($mciok(status [ $da ] length track [ %ctrak ] ) - %trakpos))
  did -o dz.cdplayer 103 1 $hms(%cdpos)
  did -o dz.cdplayer 105 1 $hms($calc($mciok(status [ $da ] length ) - %cdpos))

  set %dz.cdplayer.ctrack %ctrak
}
alias -l hms {
  var %h,%m,%s
  if ( $1 <= 0 ) return 00:00:00
  set %h $int($calc($1 /1000))
  set %s $calc(%h % 60)
  dec %h %s
  set %m $int($calc((%h % 3600) / 60))
  dec %h %m
  set %h $int($calc(%h / 3600))
  if ($len(%s) < 2) set %s 0 $+ %s
  if ($len(%m) < 2) set %m 0 $+ %m
  if ($len(%h) < 2) set %h 0 $+ %h
  return %h $+ : $+ %m $+ : $+ %s

}

on *:DIALOG:dz.cdplayer:init:0:{
  dll $mdx SetMircVersion $version
  dll $mdx MarkDialog $dname $dialog($dname).hwnd
  if (%unome == 1) {
    dll $mdx SetDialog $dname bgcolor $rgb(0,72,170)
    dll $mdx SetColor $dname 49,99 background $rgb(255,134,0)
    dll $mdx  SetColor $dname 105,50,51,52,54,55,56,57,58,59,60,61,100,101,102,103,104,405,500 background $rgb(0,72,170)
    dll $mdx  SetColor $dname 105,50,51,52,54,55,56,57,58,59,60,61,100,101,102,103,104,405,500 textbg $rgb(0,72,170)
    dll $mdx  SetColor 105,50,51,52,54,55,56,57,58,59,60,61,100,101,102,103,104,405,500 text $rgb(255,255,255)
    dll $mdx  SetColor $dname 106,1,2,3,4,5,6,7,499 background $rgb(0,72,170)
  }
  if (%unome == 2) {
    dll $mdx SetDialog $dname bgcolor $rgb(0,0,95)
    dll $mdx SetColor $dname 49,99 background $rgb(196,196,196)
    dll $mdx  SetColor $dname 105,50,51,52,54,55,56,57,58,59,60,61,100,101,102,103,104,405,500 background $rgb(0,0,95)
    dll $mdx  SetColor $dname 105,50,51,52,54,55,56,57,58,59,60,61,100,101,102,103,104,405,500 textbg $rgb(0,0,95)
    dll $mdx  SetColor 105,50,51,52,54,55,56,57,58,59,60,61,100,101,102,103,104,405,500 text $rgb(255,255,255)
    dll $mdx  SetColor $dname 106,1,2,3,4,5,6,7,499 background $rgb(0,0,95)
  }
  var %err, %errcode, %triedonce
  :tryagain
  set %err $mci(open cdaudio alias [ $da ] )
  if ( $gettok( %err ,1,32) != OK ) {
    set %errcode $gettok( %err ,2,32)
    if ( %errcode == MMSYSTEM291 ) did -o dz.cdplayer 500 1 Cannot control CD: Drive is in use
    else if (( %errcode == MMSYSTEM289 ) && ( %triedonce == $null )) {
      mci close $da
      set %triedonce 1
      goto tryagain
    }
    else did -o dz.cdplayer 500 1 Cannot control CD: $gettok( %err ,3-,32)
  }
  unset %dz.cdplayer.ctrack
  set-caps
  .timerdz.CDPlayer.forcecaps -o 0 1 set-caps
}
on *:DIALOG:dz.cdplayer:sclick:1:{
  mci set $da door open
  did -b dz.cdplayer 3,4,5,6,7
}
on *:START:{
  unset %dz.cdplayer.*
}
on *:DIALOG:dz.cdplayer:sclick:2:mci set $da door closed
on *:DIALOG:dz.cdplayer:sclick:3:mci stop $da
on *:DIALOG:dz.cdplayer:sclick:4:{
  play-track $did(51).sel
  halt
}
on *:DIALOG:dz.cdplayer:sclick:5:{
  var %status
  if ( $gettok( $mci(set [ $da ] time format msf ) ,1,32) != OK ) return
  set %status $mciok(status [ $da ] mode)
  if ( %status == playing ) {
    set %dz.cdplayer.pauseinfo $mciok(status [ $da ] position)
    mci stop $da
  }
  else if (( %status == stopped ) && ( %dz.cdplayer.pauseinfo != $null )) {
    mci play $da from %dz.cdplayer.pauseinfo
    unset %dz.cdplayer.pauseinfo
  }
  set-caps
}
on *:DIALOG:dz.cdplayer:sclick:6:{
  var %ct
  if (( $mciok( capability [ $da ] device type ) != cdaudio ) || ( $mciok( status [ $da ] mode ) == open )) return
  set %ct $mciok(status [ $da ] current track )
  if ( %ct == $null ) return
  else if ( %ct <= 1 ) play-track 1
  else {
    mci set $da time format ms
    if ( $calc( $mciok( status [ $da ] position ) - $mciok( status [ $da ] position track [ %ct ] )) > 5000 ) play-track %ct
    else play-track $calc(%ct -1)
  }
}
on *:DIALOG:dz.cdplayer:sclick:7:{
  var %ct, %mt
  if (( $mciok( capability [ $da ] device type ) != cdaudio ) || ( $mciok( status [ $da ] mode ) == open )) return
  set %ct $mciok(status [ $da ] current track )
  set %mt $mciok(status [ $da ] number of tracks )
  if ( %ct == $null ) return
  else if ( %ct >= %mt ) mci stop $da
  else play-track $calc( %ct + 1)
}
on *:DIALOG:dz.cdplayer:sclick:51:{
  var %playstat = $mciok(status [ $da ] mode)
  if (( %playstat != playing ) || ( $did(51).sel == $mciok(status [ $da ] current track ) )) return
  play-track $did(51).sel
  set %dz.cdplayer.ctrack 0
}
on *:DIALOG:dz.cdplayer:sclick:106:mixer src cd volume
on *:DIALOG:dz.cdplayer:sclick:499:{
  .timerdz.CDPlayer.forcecaps off
  mci close $da
  unset %dz.cdplayer.*
}
alias -l play-track {
  var %trackstart
  set %trackstart $mciok( status [ $da ] position track [ $1 ] )
  if ( %trackstart == $null ) return
  mci play $da from %trackstart
}

;Opens up the mixer, and if any parameters are given, will open on the specified type and control
;In this case we're only going to use:
;   /mixer src cd
;or
;   /mixer src cd volume
alias mixer {
  var %l, %linen, %conn, %cmax
  if ( $dialog(dz.mixer) ) {
    dialog -v dz.mixer
    if ( $1 == src ) {
      did -cf dz.mixer 3
      did -u dz.mixer 4
      mixer-line-fill
    }
  }
  else dialog -md dz.mixer mixer 
  if ( %cc181p == on ) { $tunder TDDialog $dialog(dz.mixer).hwnd > 10 }
  if ( $1 == dst ) {
    did -u dz.mixer 3
    did -cf dz.mixer 4
    mixer-line-fill

  }
  if ((( $1 != src ) && ( $1 != dst )) || ( $2 == $null )) return
  set %cmax $dll($udll,GetLineInfo, [ $1 ] 0 )
  if ( %cmax == 0 ) return
  set %l 0
  :lscan
  inc %l
  if ( %l > %cmax ) goto ldone
  if ( $dll($udll,GetLineInfo, [ $1 ] [ %l ] type) == $1-2 ) {
    set %linen %l
    did -c dz.mixer 5 %l
    mixer-control-fill
    goto ldone
  }
  goto lscan
  :ldone
  if (( %linen == $null ) || ( $3 == $null )) return
  set %cmax $dll($udll,GetControlInfo, [ $1 ] [ %linen ] 0 )
  if ( %cmax == 0 ) return
  set %l 0
  :cscan
  inc %l
  if ( %l > %cmax ) return
  if ( $dll($udll,GetControlInfo, [ $1 ] [ %linen ] [ %l ] type) == $3 ) {
    did -c dz.mixer 6 %l
    set %dz.mixer.ctrlsel %l
    return
  }
  goto cscan
}

;Mixer initialization
on *:DIALOG:dz.mixer:init:0:{
  dll $mdx SetMircVersion $version
  dll $mdx MarkDialog $dname $dialog($dname).hwnd
  if (%unome == 1) {
    dll $mdx SetDialog $dname bgcolor $rgb(0,72,170)
    dll $mdx SetColor $dname 2 background $rgb(255,134,0)
    dll $mdx  SetColor $dname 3,30,4,40,11,12,7,8,9,10,13,130 background $rgb(0,72,170)
    dll $mdx  SetColor $dname 3,30,4,40,11,12,7,8,9,10,13,130 textbg $rgb(0,72,170)
    dll $mdx  SetColor 3,30,4,40,11,12,7,8,9,10,13,130 text $rgb(255,255,255)
    dll $mdx  SetColor $dname 500 background $rgb(0,72,170)
  }
  if (%unome == 2) {
    dll $mdx SetDialog $dname bgcolor $rgb(0,0,95)
    dll $mdx SetColor $dname 2 background $rgb(196,196,196)
    dll $mdx  SetColor $dname 3,30,4,40,11,12,7,8,9,10,13,130 background $rgb(0,0,95)
    dll $mdx  SetColor $dname 3,30,4,40,11,12,7,8,9,10,13,130 textbg $rgb(0,0,95)
    dll $mdx  SetColor 3,30,4,40,11,12,7,8,9,10,13,130 text $rgb(255,255,255)
    dll $mdx  SetColor $dname 500 background $rgb(0,0,95)
  }
  did -c dz.mixer 3
  mixer-line-fill
  .timerdz.MixerUpdate -mo 0 1 show-mixer-value
}

;Resets the mixer line stuff if radio buttons change
on *:DIALOG:dz.mixer:sclick:3,4:mixer-line-fill

;Resets the line control stuff if mixer line changes
on *:DIALOG:dz.mixer:sclick:5:mixer-control-fill
on *:DIALOG:dz.mixer:sclick:6:set %dz.mixer.ctrlsel $did(6).sel

;Used to set the value of non-boolean controls
on *:DIALOG:dz.mixer:edit:9:{
  set %dz.mixer.noupdate 1
  .timerdz.unup -mo 1 500 mixer-unup
}

;Sets the value of boolean controls
on *:DIALOG:dz.mixer:sclick:13:{
  var %type
  if ( $did(dz.mixer,4).state == 1) set %type dst
  else set %type src
  if (( %dz.mixer.ctrlsel == $null ) || ( %dz.mixer.ctrlsel == 0 )) return
  dll $udll SetControlValue %type %dz.mixer.linesel %dz.mixer.ctrlsel $did(13).state
}

;Clears mixer variables
on *:DIALOG:dz.mixer:sclick:500:unset %dz.mixer.*

;Resumes updating of value and sets control value
alias -l mixer-unup {
  var %type
  if ( $did(dz.mixer,4).state == 1) set %type dst
  else set %type src
  if (( %dz.mixer.ctrlsel == $null ) || ( %dz.mixer.ctrlsel == 0 )) return
  if ( $did(dz.mixer,9) == $null ) dll dlls\mci.dll SetControlValue %type %dz.mixer.linesel %dz.mixer.ctrlsel $dll($udll,GetControlInfo, [ %type ] [ %dz.mixer.linesel ] [ %dz.mixer.ctrlsel ] min)
  else dll dlls\mci.dll SetControlValue %type %dz.mixer.linesel %dz.mixer.ctrlsel $did(dz.mixer,9)
  unset %dz.mixer.noupdate
}

;Fills the combo box next to "Audio line" in the mixer control with source or destination mixer line names
alias -l mixer-line-fill {
  var %l, %devc, %type
  unset %dz.mixer.noupdate
  .timerdz.unup off
  if ( $did(dz.mixer,4).state == 1) set %type dst
  else set %type src
  did -r dz.mixer 5
  set %devc $dll($udll,GetLineInfo, [ %type ] 0)
  set %l 0
  :txloop
  inc %l
  if ( %l > %devc ) {
    did -c dz.mixer 5 1
    set %dz.mixer.linesel 1
    mixer-control-fill
    return
  }
  did -a dz.mixer 5 $dll($udll,GetLineInfo, [ %type ] [ %l ] )
  goto txloop
}

;Fills the combo box next to "Line Controls" in the mixer control
alias -l mixer-control-fill {
  var %l, %conc, %type, %prod
  unset %dz.mixer.noupdate
  .timerdz.unup off
  if ( $did(dz.mixer,4).state == 1) set %type dst
  else set %type src
  did -r dz.mixer 6,9
  set %prod $dll($udll,GetLineInfo, [ %type ] [ $did(dz.mixer,5).sel ] pname )
  if ( %prod == $null ) dialog -t dz.mixer Little mIRC Mixer
  else dialog -t dz.mixer Little mIRC Mixer - %prod
  set %conc $dll($udll,GetControlInfo, [ %type ] [ $did(dz.mixer,5).sel ] 0 )
  if ( %conc == 0 ) {
    set %dz.mixer.ctrlsel 0
    did -h dz.mixer 6,12,7,8,9,10,13
    return
  }
  did -v dz.mixer 6,12
  set %l 0
  :ccloop
  inc %l
  if ( %l > %conc ) {
    did -c dz.mixer 6 1
    set %dz.mixer.ctrlsel 1
    set %dz.mixer.linesel $did(dz.mixer,5).sel
    return
  }
  did -a dz.mixer 6 $dll($udll,GetControlInfo, [ %type ] [ $did(dz.mixer,5).sel ] [ %l ] name)
  goto ccloop
}
alias -l show-mixer-value {
  var %type, %line, %ctrl, %dtype, %newval
  if ( $dialog(dz.mixer) == $null ) {
    .timerdz.MixerUpdate off
    unset %dz.mixer.*
    return
  }
  if ( %dz.mixer.noupdate != $null ) return
  if ( $did(dz.mixer,4).state == 1) set %type dst
  else set %type src
  set %line %dz.mixer.linesel
  set %ctrl %dz.mixer.ctrlsel
  if ( %ctrl == 0 ) return
  set %dtype $dll($udll,GetControlInfo, [ %type ] [ %line ] [ %ctrl ] dtype)
  if ( %dtype == boolean ) {
    did -v dz.mixer 13
    did -h dz.mixer 7,8,9,10
    if ( $dll($udll,GetControlInfo, [ %type ] [ %line ] [ %ctrl ] ) ) did -c dz.mixer 13
    else did -u dz.mixer 13
  }
  else if (( %dtype == signed ) || ( %dtype == unsigned )) {
    did -h dz.mixer 13
    did -v dz.mixer 7,8,9,10
    set %newval $dll( $udll, GetControlInfo, [ %type ] [ %line ] [ %ctrl ] min )
    if ( %newval != $gettok($did(dz.mixer,7),2-,32) ) did -o dz.mixer 7 1 Min: %newval
    set %newval $dll( $udll, GetControlInfo, [ %type ] [ %line ] [ %ctrl ] )
    if ( %newval != $did(dz.mixer,9) ) did -o dz.mixer 9 1 %newval
    set %newval $dll( $udll, GetControlInfo, [ %type ] [ %line ] [ %ctrl ] max )
    if ( %newval != $gettok($did(dz.mixer,10),2-,32) ) did -o dz.mixer 10 1 Max: %newval
  }
}
alias -l da return mirccd
alias -l mciok {
  var %mcis = $mci($1-)
  if ( $gettok( %mcis ,1,32) != OK ) return
  return $gettok( %mcis ,2-,32)
}
alias -l mci return $dll($udll,MCIString,$1-)
alias -l udll return $mircdirdlls\MCI.dll

alias __wd writeini -n $shortfn($__data) $1 $2-
alias __rd return $readini($__data,$1,$2-)
alias __data return $shortfn($scriptdirsys\data.ini)

alias toolp { if (%unome == 2) {  dialog -m lopo lopo } | else { dialog -m lopo1 lopo1 } }
alias toolp1 { if (%unome == 1) {  dialog -x lopo lopo | dialog -m lopo1 lopo1 } | else { dialog -x lopo1 lopo1 | dialog -m lopo lopo } }
dialog lopo {
  title ""
  size 0 0 16000 35
  option pixels
  icon 1,  1 1 101 23,  $mircdirgraphic\sith_buttons\2\t1.bmp, push
  icon 6,  102 1 101 23,  $mircdirgraphic\sith_buttons\2\t3.bmp, push
  icon 7,  203 1 101 23,  $mircdirgraphic\sith_buttons\2\t4.bmp, push
  icon 8,  304 1 101 23,  $mircdirgraphic\sith_buttons\2\t2.bmp, push
  text "Lag:", 2, 540 6 20 13
  text "", 3, 570 6 200 15     
  text "", 5, 800 6 50 13
  text "Arcan]G[elo 2", 4, 900 6 78 13
}
dialog lopo1 {
  title ""
  size 0 0 16000 35
  option pixels
  icon 1,  1 1 101 23,  $mircdirgraphic\sith_buttons\1\t1.bmp, push
  icon 6,  102 1 101 23,  $mircdirgraphic\sith_buttons\1\t3.bmp, push
  icon 7,  203 1 101 23,  $mircdirgraphic\sith_buttons\1\t4.bmp, push
  icon 8,  304 1 101 23,  $mircdirgraphic\sith_buttons\1\t2.bmp, push
  text "Lag:", 2, 540 6 20 13
  text "", 3, 570 6 200 15     
  text "", 5, 800 6 50 13
  text "Arcan]G[elo 2", 4, 900 6 78 13
}
on *:dialog:lopo*:init:0:{
  dll dlls/mdx/mdx.dll SetMircVersion $version 
  dll dlls/mdx/mdx.dll MarkDialog $dname 
  dll dlls/mdx/mdx.dll SetBorderStyle 1
  dll dlls/mdx/mdx.dll SetDialog $dname style
  dll dlls/mdx/mdx.dll SetColor $dname 4 text $rgb(165,173,178)  
  dll dlls/mdx/mdx.dll SetColor 2,5 text $rgb(165,173,178)
  if (%unome == 1) { dll dlls/mdx/mdx.dll SetDialog $dname bgcolor $rgb(0,72,170) | dll dlls/mdx/mdx.dll SetColor $dname 2,4,5 textbg $rgb(0,72,170) | dll dlls/mdx/mdx.dll SetColor $dname 2,4,5 background $rgb(0,72,170) } | else { dll dlls/mdx/mdx.dll SetDialog $dname bgcolor $rgb(0,0,95) |  dll dlls/mdx/mdx.dll SetColor $dname 2,4,5 textbg $rgb(0,0,95) | dll dlls/mdx/mdx.dll SetColor $dname 2,4,5 background $rgb(0,0,95) }
  dll dlls/mdx/mdx.dll SetColor 2,3,4 background $rgb(0,0,0)
  dll dlls/mdx/mdx.dll SetFont $dname 4 +a 13 800 Tahoma   
  dll dlls/mdx/mdx.dll SetControlMDX $dname 1 toolbar list noresize flat nodivider > dlls/mdx/bars.mdx 
  dll dlls/mdx/mdx.dll SetControlMDX 3, Progressbar smooth > dlls\mdx\ctl_gen.mdx
  did -a $dname 3 0 1 100
  if (%unome == 1) dll dlls/mDock61.dll DockToolbar $dialog($dname).hwnd | else dll dlls/mDock61.dll DockToolbar $dialog($dname).hwnd
}
on *:dialog:lopo*:sclick:1:{ if ($scid($activecid).$server = $null) { scid $activecid server } | else { scid $activecid quit } }
on *:dialog:lopo*:sclick:6:{ mutp }
on *:dialog:lopo*:sclick:7:{ nlist } 
on *:dialog:lopo*:sclick:8:{ toolattivo1r | toolattivof } 

on *:dialog:lopo*:init:0:{
  did -a $dname 3 4
}
on *:CONNECT:{
  .timerlag -i 0 5  { lagbar }

}
alias lagbar {
  if ($server) {
    %pingo = $ticks | .raw ping $ticks 
  }
}
on ^*:PONG: {
  %tolo = $calc(($ticks - %pingo) / 1000))
  if ( %tolo > 50 ) { %tolo = 50 } 
  %tolol = $calc((%tolo * 100)/50)
  %tolol = $round(%tolol,0)
  %tolo = $round(%tolo,2)
  lagbarl %tolol
  unset %pingo 
  haltdef
}
alias lagbarl { 
  if (%unome == 2) { did -a lopo 3 $1 0 100 |  did -a lopo 5 %tolo sec  } | else { did -a lopo1 3 $1 0 100 |  did -a lopo1 5 %tolo sec  } 
}
