Valhalla Legends Forums Archive | Battle.net Bot Development References | [VB6] Adding Multiple Icons to a ListView

AuthorMessageTime
guest!
I was wondering if there is any way i would be able to add two icons to a listview item
for example,

PRoductIconHere Username LagIconHere
ive tried many different ways but cant figure it out, plz help

[edit 4-14-05: updated title]
March 2, 2003, 5:23 PM
Camel
[code]    With lvUsers.ListItems.add(, Acct, Acct) 'sName)
       .SmallIcon = GetIcon(StatStr, Flags)
       .ListSubItems.add , , Ping, LagBars(GetLag(Ping, Flags))
   End With[/code]
March 2, 2003, 6:34 PM
haZe
[quote][code]    With lvUsers.ListItems.add(, Acct, Acct) 'sName)
       .SmallIcon = GetIcon(StatStr, Flags)
       .ListSubItems.add , , Ping, LagBars(GetLag(Ping, Flags))
   End With[/code][/quote]
wouldn't [code]    With lvUsers
               .ListItems.add(, Acct, Acct) 'sName)
               .SmallIcon = GetIcon(StatStr, Flags)
               .ListSubItems.add , , Ping, LagBars(GetLag(Ping, Flags))
   End With[/code]
be the proper way? you had with lvusers and .listitems in the same line, if u were gonna do that then take out the with :/

March 2, 2003, 9:40 PM
Atom
uh no, anyways in order to actually answer your question, go to custom under the listview's propertys and add a new column then do what the first guy said
March 3, 2003, 12:49 AM
gusest
both of those dont work..
March 3, 2003, 4:59 PM
Camel
[quote]
wouldn't [code]    With lvUsers
               .ListItems.add(, Acct, Acct) 'sName)
               .SmallIcon = GetIcon(StatStr, Flags)
               .ListSubItems.add , , Ping, LagBars(GetLag(Ping, Flags))
   End With[/code]
be the proper way? you had with lvusers and .listitems in the same line, if u were gonna do that then take out the with :/

[/quote]

no, lvUsers.ListItems.add returns a ListItem object. you have to set <listsubitem>.SmallIcon to the product icon, and <listitem>.ListSubItems(whatever).ReportIcon to the ping icon
my code was correct. if you wanted to clean it up, you could do something like:

[code]dim li as ListItem
set li = lvUsers.ListItemas.Add(, Acct, Acct)
li.SmallIcon = ...
li.ListSubItems.Add ...
[/code]


your first line of code would be correct, but after that it would not work:
lvUsers.SmallIcon = GetIcon(StatStr, Flags)
lvUsers.ListSubItems.add , , Ping, LagBars(GetLag(Ping, Flags))
a listview doesn't even have those properties
March 3, 2003, 5:15 PM
dghdghdg
I get an error saying "Index Out Of Bounds"
while doing that
March 3, 2003, 5:24 PM
Guest
Ahh, scratch out the above message (posted by me)
When i do that it shows the item like it normally would (no lagicon)
 Dim li As ListItem
 Set li = ChannelList.ListItems.add(, username, username)
 li.SmallIcon = icon
 li.ListSubItems.add , , , laGicon
March 3, 2003, 5:27 PM
Camel
[quote]Ahh, scratch out the above message (posted by me)
When i do that it shows the item like it normally would (no lagicon)
 Dim li As ListItem
 Set li = ChannelList.ListItems.add(, username, username)
 li.SmallIcon = icon
 li.ListSubItems.add , , , laGicon[/quote]

make sure you have your imagelists set up correctly. the product icon ("icon" in your code) comes from the imagelist assigned to smallicon, but the lag icon ("laGicon") comes from the ReportIcon image list (it is possible to use the same imagelist for both, but you need to make sure your code is correct in aquiring the icon's number)

the other problem could be that you don't have enough columns set up.
March 3, 2003, 5:34 PM
guest
All my code is correct for geticon and getlagcode, and i have 4 colums in my channellist. The imagelist is all the same, (all of the icons are in one list)

Here is my module3 ' get icon & lag codes '

[code]
'Image Constants
Public Const ICON_GAVEL    As Integer = 1
Public Const ICON_CHAT     As Integer = 2
Public Const ICON_DRTL     As Integer = 3
Public Const ICON_DSHR     As Integer = 4
Public Const ICON_D2DV     As Integer = 5
Public Const ICON_STAR     As Integer = 6
Public Const ICON_SSHR     As Integer = 7
Public Const ICON_SPAWN    As Integer = 8
Public Const ICON_SEXP     As Integer = 9
Public Const ICON_W2BN     As Integer = 10
Public Const ICON_JSTR     As Integer = 11
Public Const ICON_QUES     As Integer = 12
Public Const ICON_D2XP     As Integer = 13
Public Const ICON_SQUELCH  As Integer = 14
Public Const ICON_LAG1     As Integer = 15
Public Const ICON_LAG2     As Integer = 16
Public Const ICON_LAG3     As Integer = 17
Public Const ICON_LAG4     As Integer = 18
Public Const ICON_LAG5     As Integer = 19
Public Const ICON_LAG6     As Integer = 20
Public Const ICON_PLUG     As Integer = 21
Public Const ICON_ROG0     As Integer = 22
Public Const ICON_ROG1     As Integer = 23
Public Const ICON_ROG2     As Integer = 24
Public Const ICON_ROG3     As Integer = 25
Public Const ICON_SOR0     As Integer = 26
Public Const ICON_SOR1     As Integer = 27
Public Const ICON_SOR2     As Integer = 28
Public Const ICON_SOR3     As Integer = 29
Public Const ICON_WAR0     As Integer = 30
Public Const ICON_WAR1     As Integer = 31
Public Const ICON_WAR2     As Integer = 32
Public Const ICON_WAR3     As Integer = 33
Public Const ICON_SC0W     As Integer = 34
Public Const ICON_SC1W     As Integer = 35
Public Const ICON_SC2W     As Integer = 36
Public Const ICON_SC3W     As Integer = 37
Public Const ICON_SC4W     As Integer = 38
Public Const ICON_SC5W     As Integer = 39
Public Const ICON_SC6W     As Integer = 40
Public Const ICON_SC7W     As Integer = 41
Public Const ICON_SC8W     As Integer = 42
Public Const ICON_SC9W     As Integer = 43
Public Const ICON_SC10W    As Integer = 44
Public Const ICON_SCL      As Integer = 45
Public Const ICON_SCT10    As Integer = 46
Public Const ICON_SC       As Integer = 47
Public Const ICON_WC0W     As Integer = 48
Public Const ICON_WC1W     As Integer = 49
Public Const ICON_WC2W     As Integer = 50
Public Const ICON_WC3W     As Integer = 51
Public Const ICON_WC4W     As Integer = 52
Public Const ICON_WC5W     As Integer = 53
Public Const ICON_WC6W     As Integer = 54
Public Const ICON_WC7W     As Integer = 55
Public Const ICON_WC8W     As Integer = 56
Public Const ICON_WC9W     As Integer = 57
Public Const ICON_WC10W    As Integer = 58
Public Const ICON_WCL      As Integer = 59
Public Const ICON_JSTRSPAWN    As Integer = 60
Public Const ICON_3RAW As Integer = 61
Public Const ICON_BLIZZ     As Integer = 62
Public Const ICON_GLASSES  As Integer = 63
Public Const ICON_SYSOP    As Integer = 64
Public Const ICON_CBOT    As Integer = 65
Public Const ICON_SKULL    As Integer = 66

'Flags Constants
Public Const BNFLAGS_BLIZZ = &H1
Public Const BNFLAGS_OP = &H2
Public Const BNFLAGS_SPKR = &H4
Public Const BNFLAGS_SYSOP = &H8
Public Const BNFLAGS_PLUG = &H10
Public Const BNFLAGS_SQUELCH = &H20
Public Const BNFLAGS_GLASSES = &H40
Public Function GetIconCode(Optional ByVal Client As String, Optional ByVal Flags As Long) As Integer
Dim Code As Integer
Dim pA() As String
Dim Spawn As Integer
Dim stats As Boolean
On Error GoTo GetIconCode_Error
If Len(Client) > 4 Then stats = True
If Len(Client) <> 0 Then
statstring = Client


   If (BNFLAGS_BLIZZ And Flags) = BNFLAGS_BLIZZ Then
       GetIconCode = ICON_BLIZZ
       Exit Function
   ElseIf (BNFLAGS_OP And Flags) = BNFLAGS_OP Then
       GetIconCode = ICON_GAVEL
       Exit Function
   ElseIf (BNFLAGS_SYSOP And Flags) = BNFLAGS_SYSOP Then
       GetIconCode = ICON_SYSOP
       Exit Function
   ElseIf (BNFLAGS_SQUELCH And Flags) = BNFLAGS_SQUELCH Then
       GetIconCode = ICON_SQUELCH
       Exit Function
   ElseIf (BNFLAGS_GLASSES And Flags) = BNFLAGS_GLASSES Then
       GetIconCode = ICON_GLASSES
       Exit Function
   ElseIf Flags = 48 Then
       GetIconCode = ICON_SQUELCH
       Exit Function
   ElseIf Flags = 0 Then: GoTo Product
   End If
Product:
Select Case Mid(Client, 1, 4)
 Case "TAHC"
     Code = ICON_CHAT
 Case "RATS"
     Code = ICON_STAR
 Case "RTSJ"
     Code = ICON_JSTR
     If stats Then
     pA = Split(Mid(Client, 6), " ", 10)
     Spawn = Val(pA(3))
     If Spawn = 1 Then Code = ICON_JSTRSPAWN
     End If
 Case "RHSS"
     Code = ICON_SSHR
 Case "3WAR"
     Code = ICON_WAR3e
 Case "VD2D"
     Code = ICON_D2DV
 Case "RHSD"
     Code = ICON_DSHR
 Case "3RAW"
     Code = ICON_3RAW
 Case "PX2D"
     Code = ICON_D2XP
 Case "NB2W"
     Code = ICON_W2BN
   If stats Then
     pA = Split(Mid(Client, 6), " ", 10)
     wcwins = Val(pA(2))
     wcladder = Val(pA(5))
     Spawn = Val(pA(3))
     Code = ICON_WC0W
     End If
     
     If wcladder = 0 Then
         
             If wcwins = 0 Then
              Code = ICON_WC0W
             ElseIf wcwins = 1 Then
              Code = ICON_WC1W
             ElseIf wcwins = 2 Then
              Code = ICON_WC2W
             ElseIf wcwins = 3 Then
              Code = ICON_WC3W
             ElseIf wcwins = 4 Then
              Code = ICON_WC4W
             ElseIf wcwins = 5 Then
              Code = ICON_WC5W
             ElseIf wcwins = 6 Then
              Code = ICON_WC6W
             ElseIf wcwins = 7 Then
              Code = ICON_WC7W
             ElseIf wcwins = 8 Then
              Code = ICON_WC8W
             ElseIf wcwins = 9 Then
              Code = ICON_WC9W
             Else
              Code = ICON_WC10W
             End If
         
     Else
         Code = ICON_WCL
     End If

 Case "PXES"
   
     Code = ICON_SEXP
    If stats Then
     pA = Split(Mid(Client, 6), " ", 10)
     scwins = Val(pA(2))
     scladder = Val(pA(5))
     scrank = Val(pA(1))
     Spawn = Val(pA(3))
     Code = ICON_SCW0
     End If
    If scladder = 0 Then
         
             If scwins = 1 Then
               Code = ICON_SC1W
             ElseIf scwins = 2 Then
              Code = ICON_SC2W
             ElseIf scwins = 3 Then
              Code = ICON_SC3W
             ElseIf scwins = 4 Then
              Code = ICON_SC4W
             ElseIf scwins = 5 Then
              Code = ICON_SC5W
             ElseIf scwins = 6 Then
              Code = ICON_SC6W
             ElseIf scwins = 7 Then
              Code = ICON_SC7W
             ElseIf scwins = 8 Then
              Code = ICON_SC8W
             ElseIf scwins = 9 Then
              Code = ICON_SC9W
             ElseIf scwins = 10 Then
              Code = ICON_SC10W
             Else
              Code = ICON_SC10W
             End If
         
     Else
         Code = ICON_SCL
         If (scrank > 1) And (scrank < 999) Then
         Code = ICON_SCT10
         ElseIf scrank = 1 Then
         Code = ICON_SC
         End If
     If Spawn = 1 Then Code = ICON_SPAWN
     
 Case "LTRD"
     Code = ICON_DRTL
   If stats Then
     pA = Split(Mid(Client, 6), " ", 10)
     lvl = Val(pA(0))
     chrClass = Val(pA(1))
     dots = Val(pA(2))
     strength = Val(pA(3))
     mag = Val(pA(4))
     dex = Val(pA(5))
     vit = Val(pA(6))
     gold = Val(pA(7))
     Last = Val(pA(8))
   
     If (chrClass = 0) And (dots = 0) Then
     Code = ICON_WAR0
     ElseIf (chrClass = 0) And (dots = 1) Then
     Code = ICON_WAR1
     ElseIf (chrClass = 0) And (dots = 2) Then
     Code = ICON_WAR2
     ElseIf (chrClass = 0) And (dots = 3) Then
     Code = ICON_WAR3
     ElseIf (chrClass = 1) And (dots = 0) Then
     Code = ICON_ROG0
     ElseIf (chrClass = 1) And (dots = 1) Then
     Code = ICON_ROG1
     ElseIf (chrClass = 1) And (dots = 2) Then
     Code = ICON_ROG2
     ElseIf (chrClass = 1) And (dots = 3) Then
     Code = ICON_ROG3
     ElseIf (chrClass = 2) And (dots = 0) Then
     Code = ICON_SOR0
     ElseIf (chrClass = 2) And (dots = 1) Then
     Code = ICON_SOR1
     ElseIf (chrClass = 2) And (dots = 2) Then
     Code = ICON_SOR2
     ElseIf (chrClass = 2) And (dots = 3) Then
     Code = ICON_SOR3
   End If
End Select
End If

GetIconCode = Code
Exit Function
GetIconCode_Error:

End Function


Public Function GetLagIcon(ByVal lPing As Long, Optional ByVal Flags As Long) As Integer
Dim IconCode As Integer
If (Flags And BNFLAGS_PLUG) = BNFLAGS_PLUG Then
           GetLagIcon = ICON_PLUG
           Exit Function
End If
If (lPing >= 5) And (lPing <= 199) Then
   IconCode = ICON_LAG1
End If
If (lPing >= 200) And (lPing <= 300) Then
   IconCode = ICON_LAG2
End If
If (lPing >= 301) And (lPing <= 400) Then
   IconCode = ICON_LAG3
End If
If (lPing >= 401) And (lPing <= 600) Then
   IconCode = ICON_LAG4
End If
If (lPing >= 601) And (lPing <= 1200) Then
  IconCode = ICON_LAG5
End If
If lPing > 1201 Then
   IconCode = ICON_LAG6
End If
If (lPing < 0) Then
   IconCode = ICON_LAG6
End If
If (lPing = 0) Then
   IconCode = ICON_PLUG
End If
'If InStr(MakeDWORD(lFlags), Mid(MakeDWORD(lFlags), 3, 1), Chr(&H1)) Then IconCode = ICON_PLUG
GetLagIcon = IconCode
End Function
[/code]
Here is my channeljoin source
[code]
Private Sub Packet_OnJoin(ByVal username As String, ByVal Flags As Long, ByVal message As String, ByVal Ping As Long)
Dim icon As Integer
icon = GetIconCode(message, Flags)
Dim laGicon As Integer
laGicon = GetLagIcon(Ping, Flags)
Dim Text As String
Text = Left(message, 4)
form1.sckBot.SendData "1002 JOIN " & username & " " & Format(Flags, "0000") & " [" & StrReverse(Text) & "]" & " " & Ping & vbCrLf

form1.ChannelList.ListItems.add , , username, , icon


End Sub
[/code]
March 3, 2003, 5:48 PM
guest
Dont mind the following code, its a code i used to send info to a (secondary-like) bot that i used...

[code]
form1.sckBot.SendData "1002 JOIN " & username & " " & Format(Flags, "0000") & " [" & StrReverse(Text) & "]" & " " & Ping & vbCrLf
[/code]
March 3, 2003, 5:50 PM
Camel
all you needed to post was
[code]Private Sub Packet_OnJoin(ByVal username As String, ByVal Flags As Long, ByVal message As String, ByVal Ping As Long)
Dim icon As Integer
icon = GetIconCode(message, Flags)
Dim laGicon As Integer
laGicon = GetLagIcon(Ping, Flags)

form1.ChannelList.ListItems.add , , username, , icon
End Sub [/code]

try:

[code]Private Sub Packet_OnJoin(ByVal username As String, ByVal Flags As Long, ByVal message As String, ByVal Ping As Long)
   With form1.ChannelList.ListItems.add(, username, username, , GetIconCode(message, Flags))
      .ListSubItems.add , , , GetLagIcon(Ping, Flags)
   End With
End Sub[/code]
March 3, 2003, 6:02 PM
Guest
It still does not show the lag icon
March 3, 2003, 6:08 PM
Camel
make sure you have two or three columns
March 3, 2003, 9:44 PM
ILurker
i have 4 columns on it
March 3, 2003, 9:47 PM
Camel
well you need to expand them obviously to see the icon
make sure that the icon you're adding exists in your imagelist
March 3, 2003, 10:04 PM
ILurker
the icon does exist and they are quite expanded enough already
March 3, 2003, 10:07 PM
ILurker
ok i found out what was wrong,
i had it set as smallicon view instead of report
March 4, 2003, 12:53 AM

Search