• Welcome to Valhalla Legends Archive.
 

Channel List Question

Started by ThatOldFalcon, July 21, 2003, 02:14 PM

Previous topic - Next topic

ThatOldFalcon

Ok, I did a search for this and couldn't find anything, so I am going to ask you guys:
How can I make the people with Ops stay on the top of the channel list?
I have tried a bunch of times and its not working, so any help would be appreciated.

Thanks

Camel

You might have to search beyond 60 days to find this one, so I'll post the answer. :)

Add a (hidden) column to your listview and have it auto-sort by its value. Whenever you add/modify someone on the list, set its value to something like this:

Function SortOrder(Flags)
   'This function is used to sort users in the userlist.
   SortOrder = 60
   If Flags And &H40 Then SortOrder = 50 'blizz guest
   If Flags And &H4 Then SortOrder = 40 'speaker
   If Flags And &H2 Then SortOrder = 30 'op
   If Flags And &H8 Then SortOrder = 20 'bnet rep
   If Flags And &H1 Then SortOrder = 10 'blizz rep
End Function

Note that everything there is a variant because that's used via the script control and I dont care enough.

Adron

Shouldn't you also be storing a sequence number to make sure people appear in the order they joined? Or does the control guarantee that it won't reorder?

Camel

Quote from: Adron on July 22, 2003, 03:01 AM
Shouldn't you also be storing a sequence number to make sure people appear in the order they joined? Or does the control guarantee that it won't reorder?

As long as you dont change the column the listview is sorted by, it will stay ordered by the sorted column and then by the order they were added. To be blunt, it's not really all that important -- at least in VB -- although your concern is justified. Example of where it matters: my bot maintains the channel list in an sql database. In order to preserve the order properly I sort by what I call the 'SortOrder' column and then by the auto-assigned (primary key) ID. I do this because Access tends to re-order the userlist as it sees fit if I only order by the SortOrder column.

If one wishes to be totally explicit, he could add two sorted columns to the listview -- the first being the order of users joined and the second being the value from SortOrder(). I don't really know if this is possible, but one could sort by the order users joined and then switch to the SortOrder column, thus producing the desired results in twice the ammount of time.