Autor Tema: ucListViewEx 2.5 + clsIconList [UPDATED]  (Leído 71458 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Jen

  • Kilobyte
  • **
  • Mensajes: 54
  • Reputación: +2/-0
    • Ver Perfil
Re:ucListViewEx 2.5 + clsIconList [UPDATED]
« Respuesta #45 en: Junio 07, 2011, 10:35:46 pm »
I means Items or SubItems drag-drop at internal control or two ucListviewex control.
It just depends on how you handle de OLEDrop and OLEStartDrag by setting the datatype and what to drag (string/binary data, etc) :P

Normal drag-drop is realizable,but if we partially simulate Win7 explorer Listview Drag-Drop & Selected/Focused,it is a bit complicated but possible. We need to consider:
a. MultiSelection mode
b. create drag-drop image (if items is more than 1,paint multi Thumbnails and print number on it)
c. items on focus and on selected
d. GetItemRect and GetSubItemRect,GetTextRECT,draw drag-drop mark
e. cross groups
f. Auto scroll on H/V direction
g.Subclassing Mouse Notifications to make item Focus/Selected State on/off:
Código: [Seleccionar]
Private Const WM_LBUTTONDBLCLK          As Long = &H203
Private Const WM_RBUTTONDBLCLK           As Long = &H206
Private Const WM_MBUTTONDBLCLK         As Long = &H209

Private Const WM_KILLFOCUS          As Long = &H8
Private Const WM_SETFOCUS           As Long = &H7
Private Const WM_NOTIFY             As Long = &H4E
Private Const WM_KEYDOWN            As Long = &H100
Private Const WM_KEYUP              As Long = &H101
Private Const WM_CHAR               As Long = &H102
Private Const WM_MOUSEMOVE          As Long = &H200
Private Const WM_LBUTTONUP          As Long = &H202
Private Const WM_LBUTTONDOWN        As Long = &H201
Private Const WM_RBUTTONDOWN        As Long = &H204
Private Const WM_RBUTTONUP          As Long = &H205
Private Const WM_MBUTTONDOWN        As Long = &H207
Private Const WM_MBUTTONUP          As Long = &H208

Please play Win7 EXPLORER.exe for a while then you understand what features we want to achieve.




« última modificación: Junio 14, 2011, 09:58:16 am por Jen »

chip

  • Bytes
  • *
  • Mensajes: 16
  • Reputación: +2/-1
    • Ver Perfil
Re:ucListViewEx 2.5 + clsIconList [UPDATED]
« Respuesta #46 en: Junio 08, 2011, 02:00:36 pm »
From what I tested on XP/SP3 and VB6/SP6, GroupHeaderText can't be changed on runtime. But Vista/Win7 is OK. (Test String: ChrW$(&H6B22) & ChrW$(&H8FCE))
The Code your provided might be OK though there's a mistake:

 .cchHeader = Len(.pszHeader)  'Always is 4 because .pszHeader is defined in Long,Should be Len(newText)

Hi Jen, thanks for the comments. I looked at it further and actually cchHeader is ignored when using LVM_SETGROUPINFO, so that line should be commented out/removed:  http://msdn.microsoft.com/en-us/library/bb774769(v=vs.85).aspx


UNICODE:
Using my code, the Chinese characters ChrW$(&H6B22) & ChrW$(&H8FCE) do work on Windows XP SP3, both the IDE and compiled (vb6.exe needs manifest added). However, you will not see the characters unless you have East Asia Character support installed: http://www.cyberactivex.com/UnicodeTutorialVb.htm#Wheres_the_Beef_(Unicode)


GROUPHEADERTEXT:
From what I tested on XP/SP3 and VB6/SP6, GroupHeaderText can't be changed on runtime. But Vista/Win7 is OK. (Test String: ChrW$(&H6B22) & ChrW$(&H8FCE))

I dont know why, but, sometimes the group header text can be changed, other times no. I still don't know why :P Im testing that too on WinXP (If works in winxp it should work in vista/7 too)

raul338, I have experienced this problem too, no matter what code is used (even tried the example at vbAccelerator). Here is what I have found for Windows XP SP3:

1. Get the GroupHeaderText works (unicode/ansi).
2. Set the GroupHeaderText works (unicode/ansi).
3. Get the GroupHeaderText AFTER you Set the GroupHeaderText fails, everytime. No matter if you Set the GroupHeaderText with Unicode, or the method used to change the GroupHeaderText. It seems the Get GroupHeaderText will return "-1" everytime after you have Set the GroupHeaderText.

Possible work around for Windows XP (unless you guys have found a way to do that):

On Set GroupHeader Text:
    a.  Get the GroupHeader complete info
    b.  Remove the Group
    c.   Add the Group back with the new GroupHeader Text

Not sure how "fast" that will be or if there are any side effects. I have not had a chance to test that theory yet.


SORTING:
Looks like the ListView sorting should be changed from  "If var > var then" to use Unicode aware CompareStringW Lib "kernel32.dll":  #52 @ http://www.cyberactivex.com/UnicodeTutorialVb.htm#Sorting


Thanks !

chip

  • Bytes
  • *
  • Mensajes: 16
  • Reputación: +2/-1
    • Ver Perfil
Re:ucListViewEx 2.5 + clsIconList [UPDATED]
« Respuesta #47 en: Junio 09, 2011, 02:20:34 am »
hi again, im back with a working proof of concept:

image: http://www.convivea.com/capture.jpg

Download: http://www.convivea.com/download/ucListView2.5.chip.2011.6.09.rar

New:

GroupHeaderText:    Set Text and Get Text work on  Win 7 / Vista / XP.  Unicode works.
      note: use the text box next to the "Set Group 1" button to set your own text as the Group 1 header. If it is blank, it will use "Testing 1: & Chinese Unicode".


FilterItems:  Works in Group Mode or Single List mode (very cool! try it :) )

Also, GroupMode filter works on Win 7, Vista, XP both Service Pack 3 and Service Pack 2  (check for COM CNTRL 6.0, if not, it will default the old trick of changing the text to white/white. this Mode is for XP service pack 2 or less.)


.SelectedItem :  To provide a similar feature as the VB6 ListView control, I added a .SelectedItem property (Long, returns Item Index, not a reference to a ListViewItem).  Try double clicking a list item  (or right clicking as well)

Few other tweaks here and there  (like GroupAdd() allows Collapsible and IndexOrder parameters).

Known Issues:
Adding new items while the list is filtered does not properly auto-update the filtered listview. The ItemAdd function need to be updated.
FilterItems with Unicode probably does not work yet.



image2: http://www.convivea.com/capture2.jpg

here you can see both FilterItems modes (work the same on Win7/Vista/XP), Set Header Text on the left, .SelectedItem on the right.



EDIT:  I have found another (and better) work around to the Windows XP Set GroupHeader Text bug:

Código: [Seleccionar]
Public Property Let GroupHeaderText(ByVal GroupID As Long, newText As String)
'ADDED BY CHIP!

    If m_hListView Then
   
        Dim group   As LVGROUP_lp
        Dim lR      As Long
       
        Me.FreezePaint True
       
        If pIsXP = True Then  ' WINDOWS XP WORK AROUND
               
            'THIS WORKS BUT A NEWER WORK AROUND WAS FOUND
            'Dim x         As Long
            'Dim aGroups() As Long
               
            'ReDim aGroups(0 To Me.Count - 1) As Long
               
            'For x = 0 To Me.Count - 1
            '    aGroups(x) = Me.ItemGroup(x)
            'Next
               
            'Me.GroupRemove GroupID
            '
            'Me.GroupAdd GroupID, newText, , , , , GroupID
            '
            'For x = 0 To Me.Count - 1
            '
            '    If aGroups(x) = GroupID Then
            '
            '        Me.ItemGroup(x) = GroupID
            '
            '   End If
               
            'Next
           
            'NEW work around found:  http://users.skynet.be/oleole/Listview_grouping_feature.htm
            'Discusses the BUG with LVM_SETGROUPINFO
           
            With group
                .cbSize = Len(group)
                .mask = LVGF_HEADER Or LVGF_GROUPID
                .pszHeader = StrPtr(newText)
                .iGroupId = -100
            End With
       
            lR = SendMessageLong(m_hListView, LVM_SETGROUPINFO, GroupID, VarPtr(group))


            With group
                .mask = LVGF_GROUPID
                .iGroupId = GroupID
            End With
       
            lR = SendMessageLong(m_hListView, LVM_SETGROUPINFO, -100, VarPtr(group))

               
        Else
       
            With group
                .cbSize = Len(group)
                .mask = LVGF_HEADER
                .pszHeader = StrPtr(newText)
            End With
       
            lR = SendMessageLong(m_hListView, LVM_SETGROUPINFO, GroupID, VarPtr(group))
           
        End If
       
        Me.FreezePaint False
           
    End If
   
End Property
« última modificación: Junio 15, 2011, 03:49:21 am por chip »

Jen

  • Kilobyte
  • **
  • Mensajes: 54
  • Reputación: +2/-0
    • Ver Perfil
Re:ucListViewEx 2.5 + clsIconList [UPDATED]
« Respuesta #48 en: Junio 09, 2011, 04:18:17 am »

http://www.convivea.com/download/ucListView2.5.chip.rar


I think the file has not yet updated. When filtering,Groups are lost!
« última modificación: Junio 09, 2011, 04:21:45 am por Jen »

chip

  • Bytes
  • *
  • Mensajes: 16
  • Reputación: +2/-1
    • Ver Perfil
Re:ucListViewEx 2.5 + clsIconList [UPDATED]
« Respuesta #49 en: Junio 09, 2011, 04:41:38 am »
sorry, you are right. i forgot to update all of the files in the .rar.

EDIT:  new file uploaded:

http://www.convivea.com/download/ucListView2.5.chip.2011.6.09.rar
« última modificación: Junio 09, 2011, 04:50:04 am por chip »

Jen

  • Kilobyte
  • **
  • Mensajes: 54
  • Reputación: +2/-0
    • Ver Perfil
Re:ucListViewEx 2.5 + clsIconList [UPDATED]
« Respuesta #50 en: Junio 09, 2011, 10:42:13 pm »
sorry, you are right. i forgot to update all of the files in the .rar.

EDIT:  new file uploaded:

http://www.convivea.com/download/ucListView2.5.chip.2011.6.09.rar

Thanks for sharing. Well done!

I feel frustrated a bit. Allan Nielsen has built a Listview in year 1999. We are still working for Listview in year 2011.

Allan Nielsen:  SuperGrid - Yet Another listview control
http://www.codeproject.com/KB/list/supergrid.aspx
« última modificación: Junio 10, 2011, 10:58:15 pm por Jen »

Jen

  • Kilobyte
  • **
  • Mensajes: 54
  • Reputación: +2/-0
    • Ver Perfil
Re:ucListViewEx 2.5 + clsIconList [UPDATED]
« Respuesta #51 en: Junio 13, 2011, 06:02:28 am »
Muy buenos cambios!! ;)

Otra funcionalidad para window 7 y vista


1. Why Column Checkbox disappear after set MultiSelect =True or False on my Win7?
2. After disappear, I have to use command again to bring back Checkbox on header.
3. If we don't handle any of the notifications (HDN_ITEMCHECK and HDN_ITEMSTATEICONCLICK[/color), the default behavior is to select and unselect the items in the list view when clicking the checkbox. This isn't what I want. I want to Check on all items and keep items Selected state and Focused state.

Código: [Seleccionar]
Case HDN_ITEMCHECK
         Call CopyMemory(uNMHE, ByVal lParam, Len(uNMHE))
         RaiseEvent ColumnCheck(uNMHE.iItem, Not Me.ColumnCheckValue(uNMHE.iItem))

Edited:
   Subclass HDN_ITEMSTATEICONCLICK to prevent the default behavior.

Código: [Seleccionar]
Private m_lColumnChecked  As Long
                   
                    Case HDN_ITEMSTATEICONCLICK
                            m_lColumnChecked = -1
                            If Me.ColumnCheckStyle(uNMHE.iItem) Then
                              If Not Me.ColumnCheckValue(uNMHE.iItem) Then
                                Call CheckAll(True)
                                Me.ColumnCheckValue(uNMHE.iItem) = True
                                bHandled = True
                                lReturn = 1
                            ElseIf Me.ColumnCheckStyle(uNMHE.iItem) = True Then
                                Call CheckAll(False)
                                Me.ColumnCheckValue(uNMHE.iItem) = False
                                bHandled = True
                                lReturn = 1
                            End If
                            Call SetHeaderCheckbox(uNMHE.iItem)
                            m_lColumnChecked = uNMHE.iItem
                            End If

                     '...
                    Case LVN_ITEMCHANGED
                      '...
                       If m_lColumnChecked <> -1 Then
                          Call SetHeaderCheckbox(m_lColumnChecked)
                       End If




Public Sub CheckAll(Optional ByVal bChecked As Boolean = True)

Dim uLVI As LVITEMW

    If (m_hListView) Then
        With uLVI
            .stateMask = LVIS_STATEIMAGEMASK
            .State = &H1000& * (1 - bChecked)
            .Mask = LVIF_STATE
        End With
        Call SendMessage(m_hListView, LVM_SETITEMSTATE, -1, uLVI)
    End If

End Sub

Private Sub SetHeaderCheckbox(ByVal lColumn As Long)

Dim fChecked As Boolean
Dim i As Long
Dim uHDI As HDITEMW

    fChecked = True
    For i = 0 To Me.ItemCount - 1
        If Me.ItemChecked(i) = False Then fChecked = False: Exit For
    Next

    uHDI.Mask = HDI_FORMAT
    Call SendMessage(m_hHeader, HDM_GETITEMW, lColumn, uHDI)

    If fChecked Then uHDI.fmt = uHDI.fmt Or HDF_CHECKED Else uHDI.fmt = uHDI.fmt And Not HDF_CHECKED
    Call SendMessage(m_hHeader, HDM_SETITEMW, lColumn, uHDI)
   
End Sub
« última modificación: Junio 13, 2011, 09:41:50 pm por Jen »

igor

  • Bit
  • Mensajes: 9
  • Reputación: +1/-0
    • Ver Perfil
    • incod.ru
Re:ucListViewEx 2.5 + clsIconList [UPDATED]
« Respuesta #52 en: Junio 13, 2011, 10:42:06 pm »
Listview Drag-Drop MultiSelection
good example - http://winandfx.narod.ru/
Audica 0.6.0 source  http://winandfx.narod.ru/data/project_audica_0.6.0_src.zip
'-------------------------
ucListViewEx  = ok
« última modificación: Junio 13, 2011, 11:18:36 pm por igor »
El programa de control de brillo del monitor http://incod.ru/win/mymonic/

Jen

  • Kilobyte
  • **
  • Mensajes: 54
  • Reputación: +2/-0
    • Ver Perfil
Re:ucListViewEx 2.5 + clsIconList [UPDATED]
« Respuesta #53 en: Junio 14, 2011, 06:06:45 am »
Listview Drag-Drop MultiSelection
good example - http://winandfx.narod.ru/
Audica 0.6.0 source  http://winandfx.narod.ru/data/project_audica_0.6.0_src.zip
'-------------------------
ucListViewEx  = ok
Good application.
I like ITaskbarList3 which shows Play buttons on thumbnail window on top of Taskbar.
Ya,the drag-drop (Dropped Files & Internal Items) also works even though they are not Vista/win7 style. ;)

I am thinking how to MoveItem/InsertItem... audica use VBScript Dictionary to keep the index/Key which I don't like...

In .NET,it is very easy:
Código: [Seleccionar]
if (1 == listView1.SelectedItems.Count)

{

   ListViewItem item = listView1.SelectedItems[0];

   int index = item.Index;

   index++;

   if (index < listView1.Items.Count)

   {

      listView1.Items.Remove(item);

      listView1.Items.Insert(index, item);

      item.Selected = true;

      //listView1.Focus();

   }

}

 
« última modificación: Junio 14, 2011, 11:44:42 am por Jen »

Jen

  • Kilobyte
  • **
  • Mensajes: 54
  • Reputación: +2/-0
    • Ver Perfil
Re:ucListViewEx 2.5 + clsIconList [UPDATED]
« Respuesta #54 en: Junio 14, 2011, 09:29:17 am »

.SelectedItem :  To provide a similar feature as the VB6 ListView control, I added a .SelectedItem property (Long, returns Item Index, not a reference to a ListViewItem).  Try double clicking a list item  (or right clicking as well)


Be attention to use :

LVM_GETSELECTIONMARK and LVM_GETNEXTITEM,They might not be what you expect for MultiSelect.

Need further testing the following code:

Código: [Seleccionar]

Public Function GetSelectedItem() As Long

Dim lFlags As Long

    If m_hListView Then
        If MultiSelect Then
            GetSelectedItem = SendMessage(m_hListView, LVM_GETSELECTIONMARK, 0&, 0&)
        Else
            lFlags = LVNI_SELECTED
            If GetFocus() = m_hListView Then lFlags = lFlags Or LVNI_FOCUSED
            GetSelectedItem = SendMessage(m_hListView, LVM_GETNEXTITEM, &HFFFF, ByVal lFlags)
        End If
    End If

End Function

« última modificación: Junio 14, 2011, 09:54:51 am por Jen »

chip

  • Bytes
  • *
  • Mensajes: 16
  • Reputación: +2/-1
    • Ver Perfil
Re:ucListViewEx 2.5 + clsIconList [UPDATED]
« Respuesta #55 en: Junio 15, 2011, 03:35:15 am »
Be attention to use :
LVM_GETSELECTIONMARK and LVM_GETNEXTITEM,They might not be what you expect for MultiSelect.

Thank you Jen. My mistake. I missed that existing function because it was called "GetSelectedItem" and I was looking for "SelectedItem". It looks like if you remove the MultiSelect part, that will mimic VB6 functionality exactly as I wanted. What I have done is merged that existing function, removed what I previously added (included the m_SelectedItem in the subcass routine), and ended up with:

Código: [Seleccionar]
Public Property Get SelectedItem() As Long
   
    Dim lFlags As Long

    If m_hListView Then
            lFlags = LVNI_SELECTED
            If GetFocus() = m_hListView Then lFlags = lFlags Or LVNI_FOCUSED
            SelectedItem = SendMessage(m_hListView, LVM_GETNEXTITEM, &HFFFF, ByVal lFlags)
    End If
   
End Property


I tested on WinXP and Windows 7 and both has the same functionality as VB6's ListView.SelectedItem
« última modificación: Junio 15, 2011, 05:23:26 am por chip »

chip

  • Bytes
  • *
  • Mensajes: 16
  • Reputación: +2/-1
    • Ver Perfil
Re:ucListViewEx 2.5 + clsIconList [UPDATED]
« Respuesta #56 en: Junio 15, 2011, 04:57:01 am »
1. Why Column Checkbox disappear after set MultiSelect =True or False on my Win7?
2. After disappear, I have to use command again to bring back Checkbox on header.
3. If we don't handle any of the notifications (HDN_ITEMCHECK and HDN_ITEMSTATEICONCLICK[/color), the default behavior is to select and unselect the items in the list view when clicking the checkbox. This isn't what I want. I want to Check on all items and keep items Selected state and Focused state.

Edited:
   Subclass HDN_ITEMSTATEICONCLICK to prevent the default behavior.

1 & 2: same for me. Not sure why. is there a window msg that we need to subclass and "eat" ?
3: Here is how I have implemented both the default windows behavior (Check All / Uncheck All) as seen in Windows Explorer and provided the option to only Toggle the Selected items:

note: this is not perfect example, but atleast allows for multiple options to be used from within the ColumnCheck raised event.


Events:
Código: [Seleccionar]
Public Event ColumnCheck(Column As Long, Value As Boolean, Cancel As Boolean)
Subclass:
Código: [Seleccionar]
                                    Case HDN_ITEMSTATEICONCLICK
                                       
                                        Dim bCancel As Boolean
                                       
                                        Call CopyMemory(uNMHE, ByVal lParam, Len(uNMHE))
                                       
                                        Me.ColumnCheckValue(uNMHE.iItem) = Not Me.ColumnCheckValue(uNMHE.iItem)
                                       
                                        RaiseEvent ColumnCheck(uNMHE.iItem, Me.ColumnCheckValue(uNMHE.iItem), bCancel)
                                       
                                        If bCancel = True Then
                                            bHandled = True
                                            lReturn = 1
                                        End If


Form:

Código: [Seleccionar]
Private Sub ucListView1_ColumnCheck(Column As Long, Value As Boolean, Cancel As Boolean)
    On Error Resume Next
   
    Dim x As Long
   
    With ucListView1
       
        If .Count = 0 Then Exit Sub
       
        .FreezePaint True
       
        If (.SelectedCount < .Count) And (.SelectedCount > 0) Then
           
            Cancel = True
           
            For x = 0 To .Count - 1
           
                If .ItemSelected(x) = True Then
           
                    .ItemChecked(x) = Value
               
                End If
               
            Next
       
        Else
   
            For x = 0 To .Count - 1
           
                .ItemChecked(x) = Value
               
            Next
   
        End If
       
        .FreezePaint False
       
    End With
   
End Sub
« última modificación: Junio 15, 2011, 05:21:29 am por chip »

Jen

  • Kilobyte
  • **
  • Mensajes: 54
  • Reputación: +2/-0
    • Ver Perfil
Re:ucListViewEx 2.5 + clsIconList [UPDATED]
« Respuesta #57 en: Junio 15, 2011, 05:45:29 am »
1 & 2: same for me. Not sure why. is there a window msg that we need to subclass and "eat" ?
3: Here is how I have implemented both the default windows behavior (Check All / Uncheck All) as seen in Windows Explorer and provided the option to only Toggle the Selected items:

note: this is not perfect example, but atleast allows for multiple options to be used from within the ColumnCheck raised event.


Yes,That is another good way to control Header Checkbox behavior through Public Event. Well Done!
« última modificación: Junio 15, 2011, 06:55:56 am por Jen »

Bazooka

  • Terabyte
  • *****
  • Mensajes: 951
  • Reputación: +31/-20
  • El pibe Bazooka
    • Ver Perfil
    • Desof sistemas
Re:ucListViewEx 2.5 + clsIconList [UPDATED]
« Respuesta #58 en: Junio 16, 2011, 12:20:58 am »
En español muchachos!!!
Todos somos muy ignorantes. Lo que ocurre es que no todos ignoramos las mismas cosas.

LeandroA

  • Administrador
  • Petabyte
  • *****
  • Mensajes: 1128
  • Reputación: +151/-8
    • Ver Perfil
Re:ucListViewEx 2.5 + clsIconList [UPDATED]
« Respuesta #59 en: Junio 16, 2011, 03:11:34 am »
@Mike, no tiene porque ser en español, nosotros como programadores tenemos que conocer el ingles, y es mas fácil adaptarnos nosotros a ellos, se que puede resultar algo complicado pero es el idioma universal y tenemos que aceptarlo.

Es bueno saber que nos visitan de otros países

Además nadie exigió que el Nick se en español  ;D

English yes  ;)