How do you associate an mdx checkbox in a listview control with its control? I've tried finding topics on this in many different forums, but can't find anything concerning how to go about doing this. I've noticed that $did(<did>).sel doesn't work with mdx checkboxes for some reason. ![]()
for checkboxes, when setting listview control, you add "checkboxes" to it.
$did(<did>).sel will only work if you include "showsel". If you already are, trying using it with "rowselect" as well.
This is an example (from DC's setup dialog, the room options list).
dll $mdx.dll SetControlMDX $dname 50,56,76 ListView report checkboxes grid showsel rowselect flatsb labeltip > $views.mdx
when working with the checkboxes, you can use $did to retreive the whole line, $gettok($did(),5,32) will return a state (2 being checked, 1 being unchecked), from there, that's about all you need.
Hopefully this helps, if not you can ask me for more specifics on MSN Messenger.
Thanks bro. I already had those in there, but they weren't showing the selected number. So, what I did was to make an alias to set a variable for how many lines was in the list, and have it check each line for 2 (if checked)
"if ($gettok($did(SBD,2,%didlinez),5,32) == 2)", and that worked. So, must be some sort of bug in mdx then since $did(SBD,2).sel doesn't work.
I've never used this control with MDX before & find I'm scratching my head a bit on this one. I have a combo that stores servers I use. when I select a specific server name it display in a list all the channels I frequent on that particular server. Using MDX I've added check boxes to each channel. I want it so that if I tick a certain channel it will auto join when I connect. NAturally, the auto join part is no problem, but, how do I record & store the checked info exactly?
The list box ID is 172
Thanks guys & gals for taking the time to read this. ![]()
Get the Tech outta here!
using $did(<dname>,<id>,<line num>) you can get the information back. Remember that the first line is actually line number 2. And the second is 3, etc. From there, you will notice there there is a few parameters infront of the text, then the rest of the string and that. The 5th token (tokened by space ($chr(32))) is what indiciates if the box has been checked or unchecked. Checked = 2, Unchecked = 1.
From there, you should be able to store the information that you want based on the use of $gettok to match up any type of text. Those funny little boxes you see are normally tab characters ($chr(9)) so you could tokenize by that first, and then just use $gettok($1,5,32) or something.
It is best that you use an "echo" to see what the data looks like when using $did, so that you can see how it's been structured, and know how to modify it.
So would I need to define how many $lines of text are in the list first?
Get the Tech outta here!
You'll have to make an alias to check each line for a checked box, store the line number, and recall its text. Here is something that will help you out...
alias checked {
set %checked 1
if ($gettok($did($1,172,%checked),5,32) == 2) write checked.txt $did($1,172,%checked).text
inc %checked
if (%checked < $did($1,172).lines) goto next
}
This code will get you started. ![]()
Thanks guys. So, Warrior, I'd place that alias in the init? Sorry to be such a n00b but I've never thought about using this MDX feature before ![]()
EDIT: I've got it in the init and the sclick event for 172 but it's not even writing it to the .txt file ![]()
Get the Tech outta here!
You will need to place it in the "on *:dialog:<dname>:sclick:172:" event.. Here is a modified code...
alias checked {
var %dname $1
set %checked 1
if ($gettok($did(%dname,172,%checked),5,32) == 2) {
if (!$read(checked.txt,s,$did(%dname,172,%checked).text)) write checked.txt $did(%dname,172,%checked).text
}
inc %checked
if (%checked <= $did(%dname,172).lines) goto next
}
on *:dialog:<dname>:sclick:172:{ checked $dname }
Hmmm, ok not sure what I'm doing wrong here. It's writing the %variable "Checked 2" no problem but it's not writing to checked.txt. Also, wouldn't I also need a command in the init to show what's been previously checked when the dialog launches?/
Thanks again for your help on this one, Warrior. I really appreciate it ![]()
Get the Tech outta here!
Out of curiousity, the code you posted for me to try out - did it work on your end or was it an off the top of your head sort of thing?
Get the Tech outta here!
It was off the top of my head since I don't know what this is for.
Basically it's for storing favourite channels in a text file and displaying them in a list. I'd like the option that if they're ticked it will auto join them upon connect.
Example (using your code):
alias fav {
splay on.wav
if (!$dialog(faves)) { dialog -m faves faves }
}
dialog faves {
title "Favourites"
size -1 -1 98 94
option dbu
list 1, 4 4 90 50, size
button "Add", 2, 4 57 30 10
button "Delete", 3, 34 57 30 10
button "Join", 4, 64 57 30 10
box "", 5, -5 69 106 5
button "Close", 6, 64 80 30 10, ok cancel
}
On *:Dialog:faves:init:*: {
dll $mdx SetMircVersion $version
dll $mdx MarkDialog $dname
dll $mdx MarkDialog $dname
dll $mdx SetControlMDX $dname 1 listview rowselect showsel single grid labeltip report nosortheader checkboxes flatsb > $vdll
dll $mdx SetBorderStyle 1 staticedge
did -i $dname 1 1 headerdims 170
did -i $dname 1 1 headertext Channel
listrooms
checked
}
alias checked {
set %checked 1
if ($gettok($did($1,1,%checked),5,32) == 2) {
if (!$read(checked.txt,s,$did($1,1,%checked).text)) write checked.txt $did($1,1,%checked).text
}
inc %checked
if (%checked <= $did($1,1).lines) goto next
}
On *:Dialog:faves:sclick:1:{
checked $dname
}
alias listrooms {
var %l 1
did -r faves 1
if (!$read(Text/favourites.txt,%l)) { did -a faves 1 Directory Empty }
while (%l <= $lines(Text/favourites.txt)) { did -a faves 1 $read(Text/favourites.txt,%l)
inc %l
}
}
EDIT - found two minor bugs I'd left in & am now getting the error message: * /goto: 'next' not found (line 34, faves.mrc)
Line 34
if (%checked <= $did($1,1).lines) goto next
You'll notice the ID is now 1 instead of 172 as I stated earlier. I basically remade the dialog to play around with your coding suggestions & see how it all works ![]()
Get the Tech outta here!
Hahahaha - I just noticed that too for the loop lol cheers ![]()
Get the Tech outta here!
Hey Vegeta. I came up with this...
alias ff {
if (!%ff. [ $+ [ $1- ] ]) || (!$exists(%ff. [ $+ [ $1- ] ])) set %ff. [ $+ [ $1- ] ] $shortfn($findfile($mircdir,$1-,1))
return %ff. [ $+ [ $1- ] ]
}
alias checked {
var %dname $1
set %checked 2
echo 4 -a $did(%dname,172).sel : $gettok($did(%dname,172,%checked).text,5,32)
:next
if ($gettok($did(%dname,172,%checked),5,32) == 2) {
if (!$read(checked.txt,w,* $+ $gettok($did(%dname,172,%checked).text,6-,32))) write checked.txt $did(%dname,172,%checked).text
elseif ($gettok($did(%dname,172,%checked).text,5,32) == 1) write -dl $+ $calc(%checked - 1) checked.txt
}
inc %checked
if (%checked <= $did(%dname,172).lines) goto next
}
alias fav {
splay on.wav
if (!$dialog(faves)) { dialog -m faves faves }
}
dialog faves {
title "Favourites"
size -1 -1 98 94
option dbu
list 172, 4 4 90 50, size
button "Add", 2, 4 57 30 10
button "Delete", 3, 34 57 30 10
button "Join", 4, 64 57 30 10
box "", 5, -5 69 106 5
button "Close", 6, 64 80 30 10, ok cancel
}
On *:Dialog:faves:init:*: {
dll $ff(mdx.dll) SetMircVersion $version
dll $ff(mdx.dll) MarkDialog $dname
dll $ff(mdx.dll) MarkDialog $dname
dll $ff(mdx.dll) SetControlMDX $dname 172 listview rowselect showsel single grid labeltip report nosortheader checkboxes flatsb > $ff(views.mdx)
dll $ff(mdx.dll) SetBorderStyle 172 staticedge
did -i $dname 172 1 headerdims 170
did -i $dname 172 1 headertext Channel
listrooms
if ($exists(checked.txt)) loadbuf -ro $dname 172 checked.txt
}
alias faveslist {
var %y = 1
while (%y <= $did(faves,172).lines) {
if (sclick* !iswm $did(faves,172,%y).text) {
if (!$read(checked.txt,w,* $+ $gettok($did(faves,172,%y).text,6-,32))) write checked.txt $did(faves,172,%y).text
else {
if ($read(checked.txt,w,* $+ $gettok($did(faves,172,%y).text,6-,32))) && (* $+ $gettok($did(faves,172,%y).text,5,32) $+ * !iswm $read(checked.txt,$readn)) write -l $+ $readn checked.txt $did(faves,172,%y).text
}
}
inc %y
}
}
On *:Dialog:faves:sclick:172:{
did -i $dname $did 1 page event
tokenize 32 $did($dname,$did,1)
set %sendl $did(faves,172,$3)
.timer -m 1 320 faveslist %sendl
}
alias listrooms {
var %l 1
did -r faves 172
if (!$read(Text/favourites.txt,%l)) { did -a faves 172 Directory Empty }
while (%l <= $lines(Text/favourites.txt)) {
did -a faves 172 $read(Text/favourites.txt,%l)
inc %l
}
}
Now it adds whatever is in the favourites.txt. they will also be added to checked.txt, and whatever was checked will show a checkmark beside it when you reopn it until you uncheck it. ![]()
Thank you, Warrior. I shall give it a try & report back to you. Thank you so much for all your help. ![]()
Get the Tech outta here!
I'm not sure why, Warrior but it doesn't want to work for me
It doesn't load the .txt file to the list box nor display the checkboxes. It's doing my head in lol. I really appreciate all your help on this, though ![]()
Oddly enough - now it does work lol. No idea why, though one other script (My control panel) has completely crapped itself & didnt want to work. I've isolated the problem but cant for the life of me figure out why exactly.
Is it possible for mIRC itself to get a bug & do odd things with loaded scripts?
Get the Tech outta here!
Sign in to reply or start a new topic where your account has permission.