mIRC Home    About    Download    Register    News    Help

Print Thread
#28831 09/06/03 02:05 PM
Joined: Jan 2003
Posts: 148
K
Knappen Offline OP
Vogon poet
OP Offline
Vogon poet
K
Joined: Jan 2003
Posts: 148
How do I get a trackbar in my mp3 dialog from mdx.dll...

I want a trackbar that is like the one that is in nnscript`s mp3 player.

Does anyone know how i make it?
Thanks!

#28832 09/06/03 06:55 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
I know what you mean with mdx help. I never got their readme till i started playing with it a lot. Let me see if I can explain it.

If you open their help file then click the bars help file toward the bottom, you will now see the various bars. Now, if you click on track bar, you now have the help for it. Here is the way it works.

The top item where it says Host control: is the mirc item that it changes. So in your dialog, you are going to need a list in this case. Now, the requirements are: Should be size, but should not be hsbar, vsbar, or extsel That means just as it says. Now, lets create a demo dialog:

Code:
dialog trackbar {
  title "New Project"
  size -1 -1 150 25
  option dbu
  list 1, 0 0 150 15, size
  button "Close", 2, 115 15 35 10, okay
}


Okay, now we have a simple dialog that is easy to demonstrate on. Now, Before we can play with it, in this case we need two files specificly. And with these two files, two aliases. I like to create a dll folder in my mirc directory to place these in. Just makes it easier and not a long path to type. So say we have $mircdir\dll for the dll's Now, we need the aliases:

Code:
/mdx { return $dll(dll\mdx.dll,$1,$2-) }
/bars { return dll/bars.mdx }


Now, that will point to both the mdx dll,a nd the required file that mdx needs for bar controls. Now, lets start to play with the trackbar. We have the track with id 1 so remember that. Now, when you set a control, your always going to start with these two line:

/mdx SetMircVersion $version
/mdx MarkDialog $dname

That tells mdx we are running mirc <$version> and that we want to edit dialog <$dname>. Now, for editing id 1. Lets put this all into a initializing event:

Code:
on 1:DIALOG:trackbar:INIT:*: {
  ; initialize mdx
  /mdx SetMircVersion $version
  /mdx MarkDialog $dname
}

Okay, now anytime you work with changing an id with mdx, you have to do:

/mdx SetControlMDX <dialog> <id> <control> [properties] > <extention>

Lets try to break this down. SetControlMdx justs means we're playing with this id. The dialog is usually $dname (unless your outside of the on dialog event, the id is the one your changing, the control are the links you click next to the images in the help file. In this case "TrackBar" is the control. The properties are anything in the help file that come under the MDX Control Style Listing. In this case things like verticle, select, tooltips, etc. Now, the <extention> depends on what control your editing. A good way to figure it out is on the help file, look at the title bar. In this case it says MDX Bar Controls, v-- Help Well, the bar tells me to use the bar library. That means the > <control> control turns into > $bars (the alias was just to help with pointing to the dll).

Okay, so for this case, we can do something like...

Code:
on 1:DIALOG:trackbar:INIT:*: {
  ; initialize mdx
  /mdx SetMircVersion $version
  /mdx MarkDialog $dname
  ; set id properties
  /mdx SetControlMDX $dname 1 TrackBar noticks noautopsel &gt; $bars
}


Okay, now our listbox is identified as a trackbar Now we can play with the looks. Now, if this is for an mp3 player, that means you want it to move with the duration of the song. This means we use /did -i <dialog> <id> 1 [pos] [min] [max] So, if a song were playing we could use: /did -i $dname 1 1 $insong.pos 1 $sound($insong.fname).length That will place it wherever the song is played, and set the length of the song. Now, lets put it all together:

Code:
; required aliases
alias mdx { return $dll(dll\mdx.dll,$1,$2-) }
alias bars { return dll/bars.mdx }

; alias to open the dialog
alias trackbar {
  if ($dialog(trackbar)) /dialog -vie trackbar trackbar
  else /dialog -md trackbar trackbar
}

 ;dialog code 
dialog trackbar {
  title "New Project"
  size -1 -1 150 25
  option dbu
  list 1, 0 0 150 15, size
  button "Close", 2, 115 15 35 10, okay
}

; event
on 1:DIALOG:trackbar:INIT:*: {
  ; initialize mdx
  /mdx SetMircVersion $version
  /mdx MarkDialog $dname
  ; set id properties
  /mdx SetControlMDX $dname 1 TrackBar noticks noautopsel &gt; $bars
  ; update the trackbar
  /trackbar.update
  ; schedule updates every second
  .timertrackbar 0 1 /trackbar.update
}

; update the trackbar with song
alias trackbar.update {
  if ($dialog(trackbar)) {
    if ($insong) /did -i trackbar 1 1 params $insong.pos 1 $sound($insong.fname).length
    else /did -i trackbar 1 1 params 1 1 100
  }
  ; dialog is closed
  else .timertrackbar off
}


Now, just open it while a song is playing, and watch it move >:D


-KingTomato
#28833 09/06/03 07:25 PM
Joined: Jan 2003
Posts: 148
K
Knappen Offline OP
Vogon poet
OP Offline
Vogon poet
K
Joined: Jan 2003
Posts: 148
I`m sorry... I don`t understand...

I`ve got the trackbar in place and everything, but it isn`t moving and it doesn`t reset when stoped or song change and it doesn`t change the position of the song when I click somewhere else on the bar..

Could you explain a little closer? I have this aliases to controll mdx...:
mdx { return Mdx\mdx.dll }
ctl { return Mdx\ctl_gen.mdx }
bars { return Mdx\bars.mdx }
views { return Mdx\views.mdx }
dmu { return Mdx\dmu.dll }
mdx.load { dll $mdx SetMircVersion $version | dll $mdx MarkDialog $dname }

#28834 09/06/03 07:59 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
well, to make it easy on you--use the same properties on the trackbar for your dialog as I did on the example one:

/mdx SetControlMDX $dname 1 TrackBar noticks noautopsel > $bars

then use the trackbar.update alias. Change the dialog and id number tho. If you had

dialog mp3 {
list, 10, 1 1 50 15, size
}

then make the alias this:

alias trackbar.update {
if ($dialog(mp3)) {
if ($insong) /did -i mp3 10 1 params $insong.pos 1 $sound($insong.fname).length
else /did -i mp3 10 1 params 1 1 100
}
; dialog is closed
else .timertrackbar off
}

and again use a timer, to have it update. set .timertrackbar 0 1 /trackbar.update


-KingTomato

Link Copied to Clipboard