Author | Message | Time |
---|---|---|
LockesRabb | The code I have works fine, but it flickers alot while it does mass resorting everytime people join or leave the channel, so I'm wondering if there's anyway to improve the code, or is there an alterative way to sort the channel list? The channel list I have is a listview by the way. You'll also see the duplication avoidance code I put in place- if you know of a better way, I'm open to suggestions. The one I have works, but if there's an alternative, that'd be more than welcome. Sorting code: [code]Public Sub SortList(ctlListView As ListView, intColulunHeaderIndex As Integer, Optional Ascending As Boolean, Optional Descending As Boolean) ctlListView.Refresh DoEvents ctlListView.Sorted = True ctlListView.SortKey = intColulunHeaderIndex If Ascending = True Then ctlListView.SortOrder = lvwAscending ElseIf Descending = True Then ctlListView.SortOrder = lvwDescending Else If ctlListView.SortOrder = lvwAscending Then ctlListView.SortOrder = lvwDescending Else ctlListView.SortOrder = lvwAscending End If End If DoEvents ctlListView.Refresh End Sub[/code] Section in user join handlers code: [code] Case &H2 'User entered On Error GoTo skipuserenteredadd Set list_item = DMBot.lstChanView.ListItems.Add(, Username, "") If Flags And &H20 Then SortOrder = 6 'Squelched icons = 10 ElseIf Flags And &H40 Then SortOrder = 4 'blizz guest ElseIf Flags And &H4 Then SortOrder = 3 'speaker ElseIf Flags And &H2 Then SortOrder = 2 'op icons = 3 ElseIf Flags And &H8 Then SortOrder = 1 'bnet rep ElseIf Flags And &H1 Then SortOrder = 0 'blizz rep Else SortOrder = 5 UserProduct = Mid(TextString, 1, 4) If UserProduct = "PXES" Then icons = 1 ElseIf UserProduct = "RATS" Then icons = 4 ElseIf UserProduct = "PX3W" Then icons = 8 ElseIf UserProduct = "3RAW" Then icons = 6 Else Icon = 1 End If End If list_item.SmallIcon = icons list_item.SubItems(1) = Username list_item.SubItems(2) = Ping list_item.SubItems(3) = SortOrder MainModule.SortList DMBot.lstChanView, 3, True, False ChannelCount = ChannelCount + 1 AddC vbGreen, Username & " has entered the channel." Username = "" skipuserenteredadd: If Err.Number <> 35602 And Err.Number <> 0 Then AddC vbRed, "RTE: " & Err.Number & ", Err Dscrp: " & Err.Description Else Err.Clear End If[/code] Thanks for any and all ideas/advice, and also for reading this, in advance! | September 24, 2005, 9:54 PM |
laurion | redraw it and it wont flicker | September 25, 2005, 2:20 PM |
LoRd | [quote author=Tazo link=topic=12898.msg129280#msg129280 date=1127658040] redraw it and it wont flicker [/quote] The redrawing is what's making it flicker. | September 25, 2005, 2:43 PM |
laurion | Oh-my bad, I didn't even read the code lol I just thought that redrawing it removed the flicker | September 25, 2005, 2:56 PM |
raylu | I wrote a channel list sorting thing that worked fine...and then I lost it. But what I did was avoid any sorting code at all. When someone joins the channel, it puts them (and everyone else) in the right place. I wrote a sub to do this and called it when Bnet sent me the users in channel and when a user joined. I used some different code for when a user aquired ops. | September 27, 2005, 12:03 AM |
Stealth | I think you can disable the listview before making changes to it to avoid the flicker as well. (.Enabled = False) | September 27, 2005, 9:50 PM |
LockesRabb | Thanks Stealth! While it didn't eliminate the flickering, that certainly reduced it by alot. | September 30, 2005, 2:58 PM |
Yoni | You should use LockWindowUpdate to disable the flickering. Call LockWindowUpdate(ctlListView.hWnd) ' stuff.. Call LockWindowUpdate(0) | September 30, 2005, 6:18 PM |