1
Visual Basic 6 / Re:ucListViewEx 2.5 + clsIconList [UPDATED]
« en: Junio 22, 2011, 11:40:53 pm »
Here is an easy way to implement Multi Column Sort (supports 2 columns) 
download: http://www.convivea.com/download/ucListView2.5.2011.6.22.chip.rar
you can also change the Sort Order of each column at any time (independent of each other), and you can change what the 2nd Sort Column is, without re-sorting or losing your first "main" column. i think its cool
http://www.convivea.com/multi_sort.png
For example, Header 1 is main and sorted first. Then Header 2 is clicked (with shift/cntrl). If you hold cntrl/shift and click Header 2, you will change only that column sort order. If you hold shift/cntrl and click Header 3, then Header 1 and Header 3 will be sorted.
Form:
Module.bas:
Also:
"The creation of footers in list-view controls is currently not supported." @ http://msdn.microsoft.com/en-us/library/bb774748.aspx
There is no Footer in a list-view control (yet).

download: http://www.convivea.com/download/ucListView2.5.2011.6.22.chip.rar
you can also change the Sort Order of each column at any time (independent of each other), and you can change what the 2nd Sort Column is, without re-sorting or losing your first "main" column. i think its cool

http://www.convivea.com/multi_sort.png
For example, Header 1 is main and sorted first. Then Header 2 is clicked (with shift/cntrl). If you hold cntrl/shift and click Header 2, you will change only that column sort order. If you hold shift/cntrl and click Header 3, then Header 1 and Header 3 will be sorted.
Form:
Código: [Seleccionar]
Private Sub ucListView1_ColumnClick(Column As Long)
On Error Resume Next
Dim ncol As Long
With ucListView1
.AllowRedraw = False
If (.Count > 1) Then
'ADDED BY CHIP! - Support for Multi Column Sort
If (m_CurrentColumn > -1) And CNTRLorSHIFT = True Then ' Multi Column Sort
For ncol = 0 To .ColumnCount - 1
If (ncol <> Column) And (ncol <> m_CurrentColumn) Then
.ColumnOrder(ncol) = soDefault
End If
Next ncol
'SORT THE NEW COLUMN AND THEN SORT THE MAIN COLUMN AGAIN AFTER
If .ColumnOrder(Column) = soAscending Then
.ColumnOrder(Column) = soDescending
ElseIf .ColumnOrder(Column) = soDescending Then
.ColumnOrder(Column) = soDefault
Else
.ColumnOrder(Column) = soAscending
End If
Select Case Column
Case 0: Call .Sort(Column, .ColumnOrder(Column), [stStringSensitive])
Case 1, 3: Call .Sort(Column, .ColumnOrder(Column), [stNumeric])
Case 2: Call .Sort(Column, .ColumnOrder(Column), [stDate])
End Select
'PREPARE SORT THE MAIN COLUMN AGAIN
Column = m_CurrentColumn
Else ' Single Column Sort
For ncol = 0 To .ColumnCount - 1
If (ncol <> Column) Then .ColumnOrder(ncol) = soDefault
Next ncol
If .ColumnOrder(Column) = soAscending Then
.ColumnOrder(Column) = soDescending
ElseIf .ColumnOrder(Column) = soDescending Then
.ColumnOrder(Column) = soDefault
Else
.ColumnOrder(Column) = soAscending
End If
End If
Select Case Column
Case 0: Call .Sort(Column, .ColumnOrder(Column), [stStringSensitive])
Case 1, 3: Call .Sort(Column, .ColumnOrder(Column), [stNumeric])
Case 2: Call .Sort(Column, .ColumnOrder(Column), [stDate])
End Select
End If
Call .ColumnFocused(Column)
m_CurrentColumn = Column
.AllowRedraw = True
End With
End SubModule.bas:
Código: [Seleccionar]
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Public Function CNTRLorSHIFT() As Boolean
On Error Resume Next
If (GetAsyncKeyState(160) And &H8000) Then ' SHIFT
CNTRLorSHIFT = True
ElseIf (GetAsyncKeyState(162) And &H8000) Then ' CTRL
CNTRLorSHIFT = True
End If
End FunctionAlso:
Why GetFooterRECT & GetFooterItemRECT failed on Win7?
"The creation of footers in list-view controls is currently not supported." @ http://msdn.microsoft.com/en-us/library/bb774748.aspx
There is no Footer in a list-view control (yet).
Im testing that too on WinXP (If works in winxp it should work in vista/7 too)