Valhalla Legends Forums Archive | Battle.net Bot Development | Vb -> ListView Question

AuthorMessageTime
gotcha_ass
Ok Im using a listview to do the members in a channel and their icon. My problem is when someone leaves the channel, the list doesnt bump up to fill in that person empty space. It just leaves an empty space until the next user joins and fills it in. Is there any code that will automatically shift everyone up when someone leaves the channel?
February 26, 2003, 1:07 AM
Grok
Use Remove method of the ListItems collection in the ListView.  The parameter is Key.

ListView1.ListItems.Remove ItemX.Key
February 26, 2003, 6:10 AM
Noodlez
listview1.refresh after you remove someone
February 26, 2003, 6:02 PM
MesiaH
are you sure its a listview, ive known listbox's to do that, but never on my listview...

and yes make sure you remove the item by its index, you can use finditem to retreive this, or store it in a subitem(pointless, but would work all the same)
February 26, 2003, 6:09 PM
gotcha_ass
I think it is the refresh that its missing
February 26, 2003, 6:30 PM
MesiaH
no because it automatically refreshes in a way, and if you refresh the list every time you do that, if you get a floodbot or something, your bot is gonna freeze up rendering it completely helpless, even after the flood bots leave, so i wouldnt reccoment it..
February 26, 2003, 6:47 PM
haZe
You don't even really have to worry about floodbots anymore on account of how strictly battle.net is enforcing their rules on rejoins/reconnects because of all the complaints on LoRd]ZeR0['s gay ass floodbot. :-/
February 26, 2003, 8:58 PM
MesiaH
no offense, but any smart programmer can sit down and make the best flood bot ever seen, and get away with it being faster than ones that already exist.
February 26, 2003, 10:21 PM
Zakath
The only people who are interested in things like floodbots (whose entire purpose is to annoy other people) are almost by definition idiots...
February 26, 2003, 10:47 PM
Camel
[quote]no because it automatically refreshes in a way, and if you refresh the list every time you do that, if you get a floodbot or something, your bot is gonna freeze up rendering it completely helpless, even after the flood bots leave, so i wouldnt reccoment it..[/quote]

make a timer and set its interval to like 10ms or something small like that. every time you you want to refresh the listview, do tmrwhatever.enabled = false and then tmrwhatever.enabled = true. that way the timer wont execute until 10ms after the "last" time you modify the list. well, vb timers suck and are inaccurate, but it works ;)
February 26, 2003, 11:52 PM
gotcha_ass
Ahhh! Its still doing it. No one else has ever had this problem? Like when the second person in the channel leaves, his places stays blank and then the next person to join fills it, I mean I can live w/ it but its annoying.

*And yes its a listview heres the code that does it, I copied it strait off AssBot(I gave it credits to)

[code]
Public Sub DelNick(ByVal strKey$)
   Dim i&
   
   If frmMain.ChannelUsers.ListItems.Count > 1 Then
       For i = 1 To frmMain.ChannelUsers.ListItems.Count
           If Left(frmMain.ChannelUsers.ListItems(i).Key, InStr(1, frmMain.ChannelUsers.ListItems(i).Key, "&") - 1) = strKey Then
               frmMain.ChannelUsers.ListItems.Remove i
               frmMain.ChannelUsers.Refresh
               Exit For
           End If
       Next i
   Else
       If Left(frmMain.ChannelUsers.ListItems(1).Key, InStr(1, frmMain.ChannelUsers.ListItems(1).Key, "&") - 1) = strKey Then
           frmMain.ChannelUsers.ListItems.Remove 1
           frmMain.ChannelUsers.Refresh
       End If
   End If
End Sub
[/code]
February 27, 2003, 1:17 AM
Camel
[quote]you can use finditem to retreive this[/quote]
February 27, 2003, 1:40 AM
MesiaH
let me see if i can modify this a bit for ya

[code]
Public Sub DelNick(ByVal strName$)
   
   frmmain.channelusers.listitems.remove frmmain.channelusers.finditem(strname$)

End Sub
[/code]

thats all you really need to do, simply.. if you want to add things like extended support for duplicated names, im sure you can do it, but initially this is all u need.
February 27, 2003, 5:25 PM
gotcha_ass
Thanks Messiah, I dont know why they put so much code into the AssBot, when all it required was that. Hopefully it'll work I'll go try it now.
February 27, 2003, 7:18 PM
Spht
Well if you actually read the function you'd see what he is searching for in the list view. Ickis has his reason for doing such things.

It is more accurate to identify users in channel by unique keys, instead of by their name. Seeing as things like two people in the channel having the same name occurs sometimes, identifying user's by their name would not work out very well at all in this case.
February 27, 2003, 7:32 PM
gotcha_ass
Oh ok, I wasnt tryin to insult him or anything, just ignorance on my part.
February 27, 2003, 7:52 PM
gotcha_ass
I was tried that code, the real simple one MesiaH posted, and it worked at first, but now I am gettin an invalid key error. Any help?
February 28, 2003, 11:46 AM
MesiaH
when your error raises, hit debug, the line of code should be highlighted yellow, look at it carefully, if you cant figure out whats causing the error, paste it on here.
March 1, 2003, 12:47 AM
gotcha_ass
Its the same simplified code you posted earlier in this thread. The error is invalid key.

[code]
Public Sub DelNick(ByVal strKey$)
       frmMain.ChannelUsers.ListItems.Remove frmMain.ChannelUsers.FindItem(strKey$)
End Sub
[/code]
March 3, 2003, 12:57 AM
MesiaH
thats your problem, i changed it to delete them by their name, not the key.
March 3, 2003, 1:29 AM
Camel
[code]lvUsers.ListItems.Remove lvUsers.FindItem(key).Index[/code]
March 3, 2003, 5:23 PM
guest
[code]
form1.ChannelList.ListItems.add , , username, , icon
form1.ChannelList.ListItems.Remove form1.ChannelList.FindItem(username).Index
[/code]
March 3, 2003, 5:32 PM
gotcha_ass
Oh my god its still doin it  ??? ??? ???
At least I dont get an error, I wish I could put up a screen shot so I can better explain it. But this is weird.
March 4, 2003, 11:10 PM
ILurker
show me the code of how you add items to the list
March 4, 2003, 11:23 PM
gotcha_ass
[code]
Public Sub AddNick(ByVal strKey$, ByVal strName$, lngIcon&)
   Dim i&
   i = frmMain.ChannelUsers.ListItems.Count + 1
   frmMain.ChannelUsers.ListItems.Add i, strKey, strName, 0, lngIcon
End Sub
[/code]
March 5, 2003, 6:52 PM
ILurker
try doing this under the user_join sub
[code]
Dim icon As Integer
icon = GetIconCode(client, Flags)
Dim lagicoN As Integer
lagicoN = GetLagIcon(Ping, Flags)

If icon = ICON_GAVEL Then
   With frmMain.ChannelUsers.ListItems.add(1, username, username, , icon)
   .ListSubItems.add , , , lagicoN
   End With
End If
If icon <> ICON_GAVEL Then
   With frmMain.ChannelUsers.ListItems.add(, , username, , icon)
   .ListSubItems.add , , , lagicoN
   End With
End If
[/code]

This is a code you could use to remove a user from the list.

[code]
form1.ChannelList.ListItems.Remove form1.ChannelList.FindItem(username).Index
form1.ChannelList.Refresh
[/code]


If you're trying to add a lag icon also, you would need to add a "ping as string" in your sub. then use that as i did with mine
March 5, 2003, 7:00 PM
Noodlez
why dont you check the flags instead of the icon? also, what about blizz reps and bnet ops?
March 6, 2003, 9:24 PM
ILurker
yeah i relized about those this morning,
March 6, 2003, 11:25 PM

Search