PureLVSORT library : sorting ListIconGadgets (and more)
Moderator: gnozal
- 
				gnozal
 - PureBasic Expert

 - Posts: 4229
 - Joined: Sat Apr 26, 2003 8:27 am
 - Location: Strasbourg / France
 - Contact:
 
Well, apparently windows only accepts bitmaps for HDM_SETITEM, so you have to transform your .ico into a .bmp. Your favorite graphic app should do it without problems.klaver wrote:Please, change the PureLVSORT_SetUserIcons func so not only [bitmap handles] are accepted but also icons.
http://msdn2.microsoft.com/en-us/library/ms671802.aspx
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
						I'm pretty sure it's possible. You should use the LVCOLUMN structure and the #LVM_SETITEM / #LVM_SETCOLUMN.
Some example:
http://rapidshare.com/files/22878983/hico.zip.html
Thanks in advance
			
			
									
									
						Some example:
http://rapidshare.com/files/22878983/hico.zip.html
Thanks in advance
- 
				gnozal
 - PureBasic Expert

 - Posts: 4229
 - Joined: Sat Apr 26, 2003 8:27 am
 - Location: Strasbourg / France
 - Contact:
 
I can't download from Rabidshare (corporate firewall).klaver wrote:I'm pretty sure it's possible. You should use the LVCOLUMN structure and the #LVM_SETCOLUMN.
But I think you are talking about something like this ?
Code: Select all
  ; using ImageLists
  LVC.LVCOLUMN 
  LVC\lv\mask = #LVCF_IMAGE 
  LVC\iImage  = Image_Index 
  SendMessage_(GadgetID(#ListIcon),#LVM_SETCOLUMN,column,@LVC) Anyway, I am using HDM_SETITEM in PureLVSORT and I will not change this for the moment. What is so difficult about using bitmaps ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
						- 
				gnozal
 - PureBasic Expert

 - Posts: 4229
 - Joined: Sat Apr 26, 2003 8:27 am
 - Location: Strasbourg / France
 - Contact:
 
I don't have XP, but you got a point.klaver wrote:Transparency.gnozal wrote:What is so difficult about using bitmaps ?
I will see what I can do, but all the examples I have seen use LVM_INSERTCOLUMN, i.e. replace PB's AddGadgetColumn() with a custom function, and this I want to avoid, so I am not sure it is possible.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
						Code: Select all
Global Win.l, hWin.l, List.l, hList.l
#LVM_GETHEADER     = 4127
#LVM_GETCOLUMN     = 4121
#LVM_GETIMAGELIST  = 4098
#LVM_SETIMAGELIST  = 4099
#LVSIL_SMALL       = 1
#LVCF_TEXT         = 4
#ILC_MASK          = 1
#ILC_COLOR32       = 32
#HDF_BITMAP_ON_RIGHT = 4096
#HDF_IMAGE           = 2048
#HDF_STRING          = 16384
#HDI_TEXT            = 2
#HDI_IMAGE           = 32
#HDI_FORMAT          = 4
#HDM_SETITEM       = 4612
#HDM_GETITEM       = 4611
Structure HDITEM
  Mask.l
  cxy.l
  pszText.l
  hbm.l
  cchTextMax.l
  fmt.l
  lParam.l
  iImage.l
  iOrder.l
  type.l
  pvFilter.l
EndStructure
Structure LVCOLUMN
  Mask.l
  fmt.l
  cx.l
  pszText.l
  cchTextMax.l
  iSubItem.l
  iImage.l
  iOrder.l
EndStructure
Procedure.l GetHeaderID(hGadget)
  ProcedureReturn SendMessage_(hGadget, #LVM_GETHEADER, 0, 0)
EndProcedure
Procedure SetHeaderImage(hGadget.l, ImageIndex.l, Column.l, Align.l)
  TextColumn.s = Space(255)
  Var.LVCOLUMN\Mask = #LVCF_TEXT
  Var\pszText = @TextColumn
  Var\cchTextMax = 255
  SendMessage_(hGadget, #LVM_GETCOLUMN, Column, @Var)
  VarHeader.HDITEM\Mask = #HDI_IMAGE | #HDI_FORMAT | #HDI_TEXT
  VarHeader\fmt = #HDF_IMAGE | Align | #HDF_STRING
  VarHeader\iImage = ImageIndex
  VarHeader\pszText = @TextColumn
  VarHeader\cchTextMax = Len(TextColumn)
  SendMessage_(GetHeaderID(hGadget), #HDM_SETITEM, Column, @VarHeader)
EndProcedure
Procedure.l GetHeaderImageIndexID(hGadget.l, Column.l)
  VarHeader.HDITEM\Mask = #HDI_IMAGE | #HDI_FORMAT
  VarHeader\fmt = #HDF_IMAGE
  VarHeader\iImage = -1 ; to be sure that this value is not an image list icon index
  SendMessage_(GetHeaderID(hGadget), #HDM_GETITEM, Column, @VarHeader)
  ProcedureReturn VarHeader\iImage
EndProcedure
Procedure WinProc(hWnd,Msg,wParam,lParam)
  result = #PB_ProcessPureBasicEvents
  Select Msg
    Case #WM_NOTIFY
      *NMHDR.NMHDR = lParam
      If *NMHDR\hWndFrom = hList ; comes from our ListIconGadget
        If *NMHDR\code = #LVN_COLUMNCLICK
          *NMLV.NMLISTVIEW = lParam
          If GetHeaderImageIndexID(hList, *NMLV\iSubItem) = 0
            SetHeaderImage(hList, 1, *NMLV\iSubItem, #HDF_BITMAP_ON_RIGHT)
          Else
            SetHeaderImage(hList, 0, *NMLV\iSubItem, #HDF_BITMAP_ON_RIGHT) ; #HDF_BITMAP_ON_LEFT = 0
          EndIf
        EndIf
      EndIf
      Result=0
  EndSelect
  ProcedureReturn result
EndProcedure
Win = OpenWindow(#PB_Any, 0, 0, 500, 300, "ListView", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) : hWin = WindowID(Win)
SetWindowCallback(@WinProc()) : CreateGadgetList(hWin)
List = ListIconGadget(#PB_Any, 0, 0, 500, 300, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection) : hList = GadgetID(List)
AddGadgetColumn(List, 1, "Surname", 150)
AddGadgetColumn(List, 2, "Address", 200)
hImgList = ImageList_Create_(16, 16, #ILC_MASK | #ILC_COLOR32, 1, 1)
ImageList_ReplaceIcon_(hImgList, -1, LoadImage_(GetModuleHandle_(0), 1, #IMAGE_ICON, 0,0,0)) ; ImageList_AddIcon
ImageList_ReplaceIcon_(hImgList, -1, LoadImage_(GetModuleHandle_(0), 2, #IMAGE_ICON, 0,0,0)) ; ImageList_AddIcon
SendMessage_(hList, #LVM_SETIMAGELIST, #LVSIL_SMALL, hImgList)
SetHeaderImage(hList, 0, 0, #HDF_BITMAP_ON_RIGHT)
SetHeaderImage(hList, 1, 1, #HDF_BITMAP_ON_RIGHT)
SetHeaderImage(hList, 0, 2, #HDF_BITMAP_ON_RIGHT)
Repeat : Delay(1) : Until WindowEvent() = #PB_Event_CloseWindow
; jaPBe Version=3.6.12.595
; ResourceType3=9
; ResourceName=1
; ResourceLanguage=0
; ResourceFile=SORT_ASC.ico
; ResourceType3=9
; ResourceName=2
; ResourceLanguage=0
; ResourceFile=SORT_DESC.ico
; Build=0
; Language=0x0000 Language Neutral
; FirstLine=54
; CursorPosition=82
; EnableXP
; ExecutableFormat=Windows
; DontSaveDeclare
; EOF
- 
				gnozal
 - PureBasic Expert

 - Posts: 4229
 - Joined: Sat Apr 26, 2003 8:27 am
 - Location: Strasbourg / France
 - Contact:
 
So transparency cannot be done without an imagelist ?klaver wrote:code
Here's an example. Icons: http://www.kakan.ovh.org/hico.zip
					Last edited by gnozal on Tue Mar 27, 2007 4:00 pm, edited 1 time in total.
									
			
									For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
						Hey, gnozal, is TRANSPERANCY the reason, why yu're using squared standard icons?gnozal wrote:I don't have XP, but you got a point.klaver wrote:Transparency.gnozal wrote:What is so difficult about using bitmaps ?
Nice idea!
PB 4.30
						Code: Select all
onErrorGoto(?Fred)I think so... I don't know other way... but you can always try with ownerdrawninggnozal wrote:So transparency cannot be done without an imagelist ?
You asked why bitmaps are a problem, now I ask - why ImageList's so big problem? You only have to create an imagelist, assign it to the ListIconGadget and that's all. The image indexes - 0 for arrow up, 1 for arrow down?
- 
				gnozal
 - PureBasic Expert

 - Posts: 4229
 - Joined: Sat Apr 26, 2003 8:27 am
 - Location: Strasbourg / France
 - Contact:
 
Does your code also work for bmp's or only for ico's ?klaver wrote:I think so... I don't know other way... but you can always try with ownerdrawninggnozal wrote:So transparency cannot be done without an imagelist ?
And there is an interesting side effect : the icons are displayed in the first column
Code: Select all
Global Win.l, hWin.l, List.l, hList.l 
#LVM_GETHEADER     = 4127 
#LVM_GETCOLUMN     = 4121 
#LVM_GETIMAGELIST  = 4098 
#LVM_SETIMAGELIST  = 4099 
#LVSIL_SMALL       = 1 
#LVCF_TEXT         = 4 
#ILC_MASK          = 1 
#ILC_COLOR32       = 32 
#HDF_BITMAP_ON_RIGHT = 4096 
#HDF_IMAGE           = 2048 
#HDF_STRING          = 16384 
#HDI_TEXT            = 2 
#HDI_IMAGE           = 32 
#HDI_FORMAT          = 4 
#HDM_SETITEM       = 4612 
#HDM_GETITEM       = 4611 
Structure HDITEM 
  mask.l 
  cxy.l 
  pszText.l 
  hbm.l 
  cchTextMax.l 
  fmt.l 
  lParam.l 
  iImage.l 
  iOrder.l 
  type.l 
  pvFilter.l 
EndStructure 
Structure LVCOLUMN 
  mask.l 
  fmt.l 
  cx.l 
  pszText.l 
  cchTextMax.l 
  iSubItem.l 
  iImage.l 
  iOrder.l 
EndStructure 
Procedure.l GetHeaderID(hGadget) 
  ProcedureReturn SendMessage_(hGadget, #LVM_GETHEADER, 0, 0) 
EndProcedure 
Procedure SetHeaderImage(hGadget.l, ImageIndex.l, column.l, align.l) 
  TextColumn.s = Space(255) 
  Var.LVCOLUMN\mask = #LVCF_TEXT 
  Var\pszText = @TextColumn 
  Var\cchTextMax = 255 
  SendMessage_(hGadget, #LVM_GETCOLUMN, column, @Var) 
  
  VarHeader.HDITEM\mask = #HDI_IMAGE | #HDI_FORMAT | #HDI_TEXT 
  VarHeader\fmt = #HDF_IMAGE | align | #HDF_STRING 
  VarHeader\iImage = ImageIndex 
  VarHeader\pszText = @TextColumn 
  VarHeader\cchTextMax = Len(TextColumn) 
  SendMessage_(GetHeaderID(hGadget), #HDM_SETITEM, column, @VarHeader) 
EndProcedure 
Procedure.l GetHeaderImageIndexID(hGadget.l, column.l) 
  VarHeader.HDITEM\mask = #HDI_IMAGE | #HDI_FORMAT 
  VarHeader\fmt = #HDF_IMAGE 
  VarHeader\iImage = -1 ; to be sure that this value is not an image list icon index 
  SendMessage_(GetHeaderID(hGadget), #HDM_GETITEM, column, @VarHeader) 
  ProcedureReturn VarHeader\iImage 
EndProcedure 
Procedure WinProc(hwnd,msg,wParam,lParam) 
  result = #PB_ProcessPureBasicEvents 
  Select msg 
    Case #WM_NOTIFY 
      *NMHDR.NMHDR = lParam 
      If *NMHDR\hwndFrom = hList ; comes from our ListIconGadget 
        If *NMHDR\code = #LVN_COLUMNCLICK 
          *NMLV.NMLISTVIEW = lParam 
          If GetHeaderImageIndexID(hList, *NMLV\iSubItem) = 0 
            SetHeaderImage(hList, 1, *NMLV\iSubItem, #HDF_BITMAP_ON_RIGHT) 
          Else 
            SetHeaderImage(hList, 0, *NMLV\iSubItem, #HDF_BITMAP_ON_RIGHT) ; #HDF_BITMAP_ON_LEFT = 0 
          EndIf 
        EndIf 
      EndIf 
      result=0 
  EndSelect 
  ProcedureReturn result 
EndProcedure 
hImgList = ImageList_Create_(16, 16, #ILC_MASK | #ILC_COLOR32, 1, 1) 
ImageList_ReplaceIcon_(hImgList, -1, LoadImage_(GetModuleHandle_(0), 1, #IMAGE_ICON, 0,0,0)) ; ImageList_AddIcon 
ImageList_ReplaceIcon_(hImgList, -1, LoadImage_(GetModuleHandle_(0), 2, #IMAGE_ICON, 0,0,0)) ; ImageList_AddIcon 
Win = OpenWindow(#PB_Any, 0, 0, 500, 300, "ListView", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) : hWin = WindowID(Win) 
SetWindowCallback(@WinProc()) : CreateGadgetList(hWin) 
List = ListIconGadget(#PB_Any, 0, 0, 500, 300, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection) : hList = GadgetID(List) 
AddGadgetColumn(List, 1, "Surname", 150) 
AddGadgetColumn(List, 2, "Address", 200) 
SendMessage_(hList, #LVM_SETIMAGELIST, #LVSIL_SMALL, hImgList) 
;SetHeaderImage(hList, 0, 0, #HDF_BITMAP_ON_RIGHT) 
;SetHeaderImage(hList, 1, 1, #HDF_BITMAP_ON_RIGHT) 
;SetHeaderImage(hList, 0, 2, #HDF_BITMAP_ON_RIGHT) 
AddGadgetItem(List, -1, "1" + Chr(10) + "2" + Chr(10) + "3")
AddGadgetItem(List, -1, "1" + Chr(10) + "2" + Chr(10) + "3")
AddGadgetItem(List, -1, "1" + Chr(10) + "2" + Chr(10) + "3")
Repeat : Delay(1) : Until WindowEvent() = #PB_Event_CloseWindowFor free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
						I modifed the code so you can use bitmaps too. Simply the ImageList_AddIcon_ function must be replaced with ImageList_Add_.gnozal wrote:Does your code also work for bmp's or only for ico's ?
Oopsgnozal wrote:And there is an interesting side effect : the icons are displayed in the first column!
http://www.kakan.ovh.org/hico.zip

Code: Select all
Global Win.l, hWin.l, List.l, hList.l
#LVM_GETHEADER     = 4127
#LVM_GETCOLUMN     = 4121
#LVM_GETIMAGELIST  = 4098
#LVSIL_SMALL       = 1
#LVCF_TEXT         = 4
#ILC_MASK          = 1
#ILC_COLOR32       = 32
#HDF_BITMAP_ON_RIGHT = 4096
#HDF_IMAGE           = 2048
#HDF_STRING          = 16384
#HDI_TEXT            = 2
#HDI_IMAGE           = 32
#HDI_FORMAT          = 4
#HDM_SETITEM         = 4612
#HDM_GETITEM         = 4611
#HDM_SETIMAGELIST    = 4616
Structure HDITEM
  mask.l
  cxy.l
  pszText.l
  hbm.l
  cchTextMax.l
  fmt.l
  lParam.l
  iImage.l
  iOrder.l
  type.l
  pvFilter.l
EndStructure
Structure LVCOLUMN
  mask.l
  fmt.l
  cx.l
  pszText.l
  cchTextMax.l
  iSubItem.l
  iImage.l
  iOrder.l
EndStructure
Procedure.l GetHeaderID(hGadget)
  ProcedureReturn SendMessage_(hGadget, #LVM_GETHEADER, 0, 0)
EndProcedure
Procedure SetHeaderImage(hGadget.l, ImageIndex.l, column.l, align.l)
  TextColumn.s = Space(255)
  Var.LVCOLUMN\mask = #LVCF_TEXT
  Var\pszText = @TextColumn
  Var\cchTextMax = 255
  SendMessage_(hGadget, #LVM_GETCOLUMN, column, @Var)
  
  VarHeader.HDITEM\mask = #HDI_IMAGE | #HDI_FORMAT | #HDI_TEXT
  VarHeader\fmt = #HDF_IMAGE | align | #HDF_STRING
  VarHeader\iImage = ImageIndex
  VarHeader\pszText = @TextColumn
  VarHeader\cchTextMax = Len(TextColumn)
  SendMessage_(GetHeaderID(hGadget), #HDM_SETITEM, column, @VarHeader)
EndProcedure
Procedure.l GetHeaderImageIndexID(hGadget.l, column.l)
  VarHeader.HDITEM\mask = #HDI_IMAGE | #HDI_FORMAT
  VarHeader\fmt = #HDF_IMAGE
  VarHeader\iImage = -1 ; to be sure that this value is not an image list icon index
  SendMessage_(GetHeaderID(hGadget), #HDM_GETITEM, column, @VarHeader)
  ProcedureReturn VarHeader\iImage
EndProcedure
Procedure WinProc(hwnd,msg,wParam,lParam)
  result = #PB_ProcessPureBasicEvents
  Select msg
    Case #WM_NOTIFY
      *NMHDR.NMHDR = lParam
      If *NMHDR\hwndFrom = hList ; comes from our ListIconGadget
        If *NMHDR\code = #LVN_COLUMNCLICK
          *NMLV.NMLISTVIEW = lParam
          If GetHeaderImageIndexID(hList, *NMLV\iSubItem) = 0
            SetHeaderImage(hList, 1, *NMLV\iSubItem, #HDF_BITMAP_ON_RIGHT)
          Else
            SetHeaderImage(hList, 0, *NMLV\iSubItem, #HDF_BITMAP_ON_RIGHT) ; #HDF_BITMAP_ON_LEFT = 0
          EndIf
        EndIf
      EndIf
      result=0
  EndSelect
  ProcedureReturn result
EndProcedure
Procedure AddToImageList(hList.l, hImg.l)
  If GetObjectType_(hImg) = #OBJ_BITMAP
    result = ImageList_Add_(hList, hImg, 0)
  Else
    result = ImageList_ReplaceIcon_(hList, -1, hImg) ; ImageList_AddIcon
  EndIf
  ProcedureReturn result
EndProcedure
hImgList = ImageList_Create_(16, 16, #ILC_MASK | #ILC_COLOR32, 1, 1)
AddToImageList(hImgList, LoadImage_(GetModuleHandle_(0), 3, #IMAGE_BITMAP, 0, 0, 0))
AddToImageList(hImgList, LoadImage_(GetModuleHandle_(0), 4, #IMAGE_BITMAP, 0, 0, 0))
AddToImageList(hImgList, LoadImage_(GetModuleHandle_(0), 1, #IMAGE_ICON, 0, 0, 0))
AddToImageList(hImgList, LoadImage_(GetModuleHandle_(0), 2, #IMAGE_ICON, 0, 0, 0))
Win = OpenWindow(#PB_Any, 0, 0, 500, 300, "ListView", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) : hWin = WindowID(Win)
SetWindowCallback(@WinProc()) : CreateGadgetList(hWin)
List = ListIconGadget(#PB_Any, 0, 0, 500, 300, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection) : hList = GadgetID(List)
AddGadgetColumn(List, 1, "Surname", 150)
AddGadgetColumn(List, 2, "Address", 200)
SendMessage_(GetHeaderID(hList), #HDM_SETIMAGELIST, 0, hImgList)
SetHeaderImage(hList, 0, 0, #HDF_BITMAP_ON_RIGHT)
SetHeaderImage(hList, 1, 1, #HDF_BITMAP_ON_RIGHT)
SetHeaderImage(hList, 2, 2, #HDF_BITMAP_ON_RIGHT)
AddGadgetItem(List, -1, "1" + Chr(10) + "2" + Chr(10) + "3")
AddGadgetItem(List, -1, "1" + Chr(10) + "2" + Chr(10) + "3")
AddGadgetItem(List, -1, "1" + Chr(10) + "2" + Chr(10) + "3")
Repeat : Delay(1) : Until WindowEvent() = #PB_Event_CloseWindow 
; jaPBe Version=3.6.12.595
; ResourceType3=3
; ResourceName=3
; ResourceLanguage=0
; ResourceFile=sm1.bmp
; ResourceType3=3
; ResourceName=4
; ResourceLanguage=0
; ResourceFile=sm2.bmp
; ResourceType3=9
; ResourceName=1
; ResourceLanguage=0
; ResourceFile=SORT_ASC.ico
; ResourceType3=9
; ResourceName=2
; ResourceLanguage=0
; ResourceFile=SORT_DESC.ico
; Build=0
; Language=0x0000 Language Neutral
; FirstLine=71
; CursorPosition=101
; EnableXP
; ExecutableFormat=Windows
; DontSaveDeclare
; EOF
Hi Gnozal,
i have a little problem with your great PureLVSort Library :roll:
When i run this example code the second time, it performs really slow :
1. Run

2. Run

With disapled PureLVSort the speed is the same as in screenshot 1 every run.
Regards Klaus
			
			
													i have a little problem with your great PureLVSort Library :roll:
When i run this example code the second time, it performs really slow :
Code: Select all
Enumeration
  #Window_Durchlaufzeiten
EndEnumeration
Enumeration
  #StatusBar_1
EndEnumeration
Enumeration
  #Durchlaufzeiten_List1
  #Durchlaufzeiten_Suchen
  #Durchlaufzeiten_Loeschen
EndEnumeration
Procedure ColorCallBack(GadgetNumber.l, CellRow.l, CellColumn.l, *TextColor.LONG, *BackColor.LONG, *FontID.LONG)
  If IsGadget(GadgetNumber)
    *FontID\l=GetGadgetFont(GadgetNumber)
  EndIf
  
  Select GadgetNumber
    Case #Durchlaufzeiten_List1
      CellText.s=GetGadgetItemText(GadgetNumber,CellRow,2)
      Select LCase(CellText)
        Case "ok"
          Col=#Green
        Case "scrapped" 
          Col=RGB(255,0,255)
        Case "rework"
          Col=RGB(0,255,255)
        Default
          Col=#White
      EndSelect
      If Col<>#Green
        *BackColor\l=Col
      EndIf
  EndSelect
EndProcedure
Procedure.l ListIconSort_Durchlaufzeiten1(ListIconNumber.l, ListIconColumn.l, Item1.s, Item2.s)
  Protected ReturnValue.l
  
  Item1=ReplaceString(Item1,sDecimal$,".")
  Item2=ReplaceString(Item2,sDecimal$,".")
  
  If ValD(Item1) > ValD(Item2)
    ReturnValue = 1
  ElseIf ValD(Item1) < ValD(Item2)
    ReturnValue = -1
  Else
    ReturnValue = 0
  EndIf
  
  ProcedureReturn ReturnValue
EndProcedure
Procedure Open_Window_Durchlaufzeiten()
  If OpenWindow(#Window_Durchlaufzeiten, 0, 0, 1024, 240, "PureLVSort Performance Bug")
    If CreateGadgetList(WindowID(#Window_Durchlaufzeiten))
      ListIconGadget(#Durchlaufzeiten_List1, 5, 40, 1005, 170, "Index", 50, #PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
      AddGadgetColumn(#Durchlaufzeiten_List1, 1,"ID",90)
      AddGadgetColumn(#Durchlaufzeiten_List1, 2,"Status",50)
      AddGadgetColumn(#Durchlaufzeiten_List1, 3,"Date 1",100)
      AddGadgetColumn(#Durchlaufzeiten_List1, 4,"Date 2",100)
      AddGadgetColumn(#Durchlaufzeiten_List1, 5,"Days",50)
      AddGadgetColumn(#Durchlaufzeiten_List1, 6,"Date 3",100)
      AddGadgetColumn(#Durchlaufzeiten_List1, 7,"Days",50)
      AddGadgetColumn(#Durchlaufzeiten_List1, 8,"Date 4",100)
      AddGadgetColumn(#Durchlaufzeiten_List1, 9,"Days",50)
      AddGadgetColumn(#Durchlaufzeiten_List1,10,"Date 5",100)
      AddGadgetColumn(#Durchlaufzeiten_List1,11,"Days",50)
      AddGadgetColumn(#Durchlaufzeiten_List1,12,"Total",50)
      ButtonGadget(#Durchlaufzeiten_Suchen, 5, 5, 100, 30, "Search")
      ButtonGadget(#Durchlaufzeiten_Loeschen, 120, 5, 100, 30, "Delete")
      
      CreateStatusBar(#StatusBar_1,WindowID(#Window_Durchlaufzeiten))
      AddStatusBarField(1024)
      AddKeyboardShortcut(#Window_Durchlaufzeiten, #PB_Shortcut_Return , 100)
      AddKeyboardShortcut(#Window_Durchlaufzeiten, #PB_Shortcut_Escape , 101)
      
      PureCOLOR_SetCellColorCallback(#Window_Durchlaufzeiten,@ColorCallBack())
    EndIf
  EndIf
EndProcedure
Procedure Button_SucheDurchlaufzeiten()
  PureLVSORT_ClearGadget(#Durchlaufzeiten_List1)
  ClearGadgetItemList(#Durchlaufzeiten_List1)
  StatusBarText(#StatusBar_1,0,"Bitte warten !")
  
  While WindowEvent():Wend
  
  StatusBarText(#StatusBar_1,0,"Please wait ! (ESC=Break)")
  
  time1=ElapsedMilliseconds()
  
  max=15000
  
  Index=0
  Quit=0
  
  For i=1 To max
    Index+1
    EPNR$="AA12345678"
    Select Random(10)
      Case 9
        Status$="REWORK"
      Case 10
        Status$="SCRAPPED"
      Default
        Status$="OK"
    EndSelect
    Date1$="1.1.2006 11:21:00"
    Date2$="1.1.2006 11:21:00"
    Days1$=Str(Random(999))
    Date3$="1.1.2006 11:21:00"
    Days2$=Str(Random(999))
    Date4$="1.1.2006 11:21:00"
    Days3$=Str(Random(999))
    Date5$="1.1.2006 11:21:00"
    Days4$=Str(Random(999))
    Days$=Str(Random(999))
    
    AddGadgetItem(#Durchlaufzeiten_List1,-1,Str(Index)+Chr(10)+EPNR$+Chr(10)+Status$+Chr(10)+Date1$+Chr(10)+Date2$+Chr(10)+Days1$+Chr(10)+Date3$+Chr(10)+Days2$+Chr(10)+Date4$+Chr(10)+Days3$+Chr(10)+Date5$+Chr(10)+Days4$+Chr(10)+Days$)
    time2=ElapsedMilliseconds()
    
    Repeat
      Event=WindowEvent()
      Select Event
        Case #PB_Event_Menu
          If EventMenu()=101
            Quit=1
            Break 2
          EndIf
        Case #PB_Event_CloseWindow
          Quit=1
          Break 2
      EndSelect
    Until Event=0
    
  Next
  
  If Quit
    StatusBarText(#StatusBar_1,0,"Process terminated")
  Else
    timediff$=ReplaceString(StrF((time2-time1)/1000,3),".",",")
    StatusBarText(#StatusBar_1,0,"TIME: "+timediff$+" sec.")
  EndIf
  
  PureLVSORT_ClearGadget(#Durchlaufzeiten_List1)
  PureLVSORT_DefineUserCallback(@ListIconSort_Durchlaufzeiten1())
  If PureLVSORT_SelectGadgetToSort(#Durchlaufzeiten_List1,#PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
    PureLVSORT_SetColumnType(#Durchlaufzeiten_List1, 0,#PureLVSORT_Numeric)
    PureLVSORT_SetColumnType(#Durchlaufzeiten_List1, 1,#PureLVSORT_String)
    PureLVSORT_SetColumnType(#Durchlaufzeiten_List1, 2,#PureLVSORT_String)
    PureLVSORT_SetColumnType(#Durchlaufzeiten_List1, 3,#PureLVSORT_DateDDMMYYYYHHMMSS)
    PureLVSORT_SetColumnType(#Durchlaufzeiten_List1, 4,#PureLVSORT_DateDDMMYYYYHHMMSS)
    PureLVSORT_SetColumnType(#Durchlaufzeiten_List1, 5,#PureLVSORT_UserCallback)
    PureLVSORT_SetColumnType(#Durchlaufzeiten_List1, 6,#PureLVSORT_DateDDMMYYYYHHMMSS)
    PureLVSORT_SetColumnType(#Durchlaufzeiten_List1, 7,#PureLVSORT_UserCallback)
    PureLVSORT_SetColumnType(#Durchlaufzeiten_List1, 8,#PureLVSORT_DateDDMMYYYYHHMMSS)
    PureLVSORT_SetColumnType(#Durchlaufzeiten_List1, 9,#PureLVSORT_UserCallback)
    PureLVSORT_SetColumnType(#Durchlaufzeiten_List1,10,#PureLVSORT_DateDDMMYYYYHHMMSS)
    PureLVSORT_SetColumnType(#Durchlaufzeiten_List1,11,#PureLVSORT_UserCallback)
    PureLVSORT_SetColumnType(#Durchlaufzeiten_List1,12,#PureLVSORT_UserCallback)
  EndIf
EndProcedure
Open_Window_Durchlaufzeiten()
Repeat
  WindowEvent   = WaitWindowEvent()
  Eventtype     = EventType()
  EventGadgetID = EventGadget()
  EventwParam   = EventwParam()
  EventFocus    = GetFocus_()
  
  Select WindowEvent
    Case #PB_Event_Gadget
      Select Eventtype
        Case #PB_EventType_LeftClick
          Select EventGadgetID
            Case #Durchlaufzeiten_Suchen
              Button_SucheDurchlaufzeiten()
            Case #Durchlaufzeiten_Loeschen
              ClearGadgetItemList(#Durchlaufzeiten_List1)
          EndSelect
      EndSelect
  EndSelect
Until WindowEvent = #PB_Event_CloseWindow2. Run
With disapled PureLVSort the speed is the same as in screenshot 1 every run.
Regards Klaus
					Last edited by ABBKlaus on Wed Mar 28, 2007 2:52 pm, edited 1 time in total.
									
			
									
						- 
				gnozal
 - PureBasic Expert

 - Posts: 4229
 - Joined: Sat Apr 26, 2003 8:27 am
 - Location: Strasbourg / France
 - Contact:
 
Thanks.klaver wrote:I modifed the code so you can use bitmaps too. Simply the ImageList_AddIcon_ function must be replaced with ImageList_Add_.gnozal wrote:Does your code also work for bmp's or only for ico's ?
I came to the same conclusion but my code doesn't work with bitmaps, your code also doesn't work if the bitmap is loaded with CatchImage().
Or am I missing something ?
Code: Select all
Global Win.l, hWin.l, List.l, hList.l 
#LVM_GETHEADER     = 4127 
#LVM_GETCOLUMN     = 4121 
#LVM_GETIMAGELIST  = 4098 
#LVSIL_SMALL       = 1 
#LVCF_TEXT         = 4 
#ILC_MASK          = 1 
#ILC_COLOR32       = 32 
#HDF_BITMAP_ON_RIGHT = 4096 
#HDF_IMAGE           = 2048 
#HDF_STRING          = 16384 
#HDI_TEXT            = 2 
#HDI_IMAGE           = 32 
#HDI_FORMAT          = 4 
#HDM_SETITEM         = 4612 
#HDM_GETITEM         = 4611 
#HDM_SETIMAGELIST    = 4616 
;  IncludeBinary "PureLVSORT_FlecheHaut.bmp"
;{ Size = 1222 bytes
DataSection
IconArrowUp:
Data.l $04C64D42,$00000000,$04360000,$00280000,$000C0000,$000C0000,$00010000,$00000008,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$C6C60000,$C8C800C6,$CECE00C8,$DEDE00CE,$EFEF00DE,$FFFF00EF,$000000FF,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$06000000,$06060606,$06060606,$06000006
Data.l $00060606,$06060600,$06000006,$00060606,$06060600,$06000006,$00060606,$06060600,$06000006,$00060606,$06060600,$06000006
Data.l $00000000,$00000000,$06000006,$00000006,$06000000,$06000006,$00000606,$06060000,$06000006,$00060606,$06060600,$06000006
Data.l $06060606,$06060606,$00000006,$00000000,$00000000
Data.b $00,$00
EndDataSection ;}
;  IncludeBinary "PureLVSORT_FlecheBas.bmp"
;{ Size = 1222 bytes
DataSection
IconArrowDown:
Data.l $04C64D42,$00000000,$04360000,$00280000,$000C0000,$000C0000,$00010000,$00000008,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$C6C60000,$C8C800C6,$CECE00C8,$DEDE00CE,$EFEF00DE,$FFFF00EF,$000000FF,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$06000000,$06060606,$06060606,$06000006
Data.l $00060606,$06060600,$06000006,$00000606,$06060000,$06000006,$00000006,$06000000,$06000006,$00000000,$00000000,$06000006
Data.l $00060606,$06060600,$06000006,$00060606,$06060600,$06000006,$00060606,$06060600,$06000006,$00060606,$06060600,$06000006
Data.l $06060606,$06060606,$00000006,$00000000,$00000000
Data.b $00,$00
EndDataSection ;}
Structure HDITEM 
  mask.l 
  cxy.l 
  pszText.l 
  hbm.l 
  cchTextMax.l 
  fmt.l 
  lParam.l 
  iImage.l 
  iOrder.l 
  type.l 
  pvFilter.l 
EndStructure 
Structure LVCOLUMN 
  mask.l 
  fmt.l 
  cx.l 
  pszText.l 
  cchTextMax.l 
  iSubItem.l 
  iImage.l 
  iOrder.l 
EndStructure 
Procedure.l GetHeaderID(hGadget) 
  ProcedureReturn SendMessage_(hGadget, #LVM_GETHEADER, 0, 0) 
EndProcedure 
Procedure SetHeaderImage(hGadget.l, ImageIndex.l, column.l, align.l) 
  TextColumn.s = Space(255) 
  Var.LVCOLUMN\mask = #LVCF_TEXT 
  Var\pszText = @TextColumn 
  Var\cchTextMax = 255 
  SendMessage_(hGadget, #LVM_GETCOLUMN, column, @Var) 
  
  VarHeader.HDITEM\mask = #HDI_IMAGE | #HDI_FORMAT | #HDI_TEXT 
  VarHeader\fmt = #HDF_IMAGE | align | #HDF_STRING 
  VarHeader\iImage = ImageIndex 
  VarHeader\pszText = @TextColumn 
  VarHeader\cchTextMax = Len(TextColumn) 
  SendMessage_(GetHeaderID(hGadget), #HDM_SETITEM, column, @VarHeader) 
EndProcedure 
Procedure.l GetHeaderImageIndexID(hGadget.l, column.l) 
  VarHeader.HDITEM\mask = #HDI_IMAGE | #HDI_FORMAT 
  VarHeader\fmt = #HDF_IMAGE 
  VarHeader\iImage = -1 ; to be sure that this value is not an image list icon index 
  SendMessage_(GetHeaderID(hGadget), #HDM_GETITEM, column, @VarHeader) 
  ProcedureReturn VarHeader\iImage 
EndProcedure 
Procedure WinProc(hwnd,msg,wParam,lParam) 
  result = #PB_ProcessPureBasicEvents 
  Select msg 
    Case #WM_NOTIFY 
      *NMHDR.NMHDR = lParam 
      If *NMHDR\hwndFrom = hList ; comes from our ListIconGadget 
        If *NMHDR\code = #LVN_COLUMNCLICK 
          *NMLV.NMLISTVIEW = lParam 
          If GetHeaderImageIndexID(hList, *NMLV\iSubItem) = 0 
            SetHeaderImage(hList, 1, *NMLV\iSubItem, #HDF_BITMAP_ON_RIGHT) 
          Else 
            SetHeaderImage(hList, 0, *NMLV\iSubItem, #HDF_BITMAP_ON_RIGHT) ; #HDF_BITMAP_ON_LEFT = 0 
          EndIf 
        EndIf 
      EndIf 
      result=0 
  EndSelect 
  ProcedureReturn result 
EndProcedure 
Procedure AddToImageList(hList.l, hImg.l) 
  If GetObjectType_(hImg) = #OBJ_BITMAP 
    result = ImageList_Add_(hList, hImg, 0) 
  Else 
    result = ImageList_ReplaceIcon_(hList, -1, hImg) ; ImageList_AddIcon 
  EndIf 
  ProcedureReturn result 
EndProcedure 
hImgList = ImageList_Create_(16, 16, #ILC_MASK | #ILC_COLOR32, 1, 1) 
AddToImageList(hImgList, ImageID(CatchImage(#PB_Any, ?IconArrowUp))) 
AddToImageList(hImgList, ImageID(CatchImage(#PB_Any, ?IconArrowDown))) 
AddToImageList(hImgList, ImageID(CatchImage(#PB_Any, ?IconArrowUp))) 
AddToImageList(hImgList, ImageID(CatchImage(#PB_Any, ?IconArrowDown))) 
Win = OpenWindow(#PB_Any, 0, 0, 500, 300, "ListView", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) : hWin = WindowID(Win) 
SetWindowCallback(@WinProc()) : CreateGadgetList(hWin) 
List = ListIconGadget(#PB_Any, 0, 0, 500, 300, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection) : hList = GadgetID(List) 
AddGadgetColumn(List, 1, "Surname", 150) 
AddGadgetColumn(List, 2, "Address", 200) 
SendMessage_(GetHeaderID(hList), #HDM_SETIMAGELIST, 0, hImgList) 
SetHeaderImage(hList, 0, 0, #HDF_BITMAP_ON_RIGHT) 
SetHeaderImage(hList, 1, 1, #HDF_BITMAP_ON_RIGHT) 
SetHeaderImage(hList, 2, 2, #HDF_BITMAP_ON_RIGHT) 
AddGadgetItem(List, -1, "1" + Chr(10) + "2" + Chr(10) + "3") 
AddGadgetItem(List, -1, "1" + Chr(10) + "2" + Chr(10) + "3") 
AddGadgetItem(List, -1, "1" + Chr(10) + "2" + Chr(10) + "3") 
Repeat : Delay(1) : Until WindowEvent() = #PB_Event_CloseWindowFor free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
						- 
				gnozal
 - PureBasic Expert

 - Posts: 4229
 - Joined: Sat Apr 26, 2003 8:27 am
 - Location: Strasbourg / France
 - Contact:
 
I have found the problem. After PureLVSORT_ClearGadget(), the ListIcon is still subclassed, and PureLVSORT is monitoring the #LVM_INSERTITEM / #LVM_DELETEITEM messages, so this explains the delay. Now, PureLVSORT_ClearGadget() also resets the subclassing.ABBKlaus wrote:Hi Gnozal,
i have a little problem with your great PureLVSort Library :roll:
With disapled PureLVSort the speed is the same as in screenshot 1 every run.
Regards Klaus
Please test http://freenet-homepage.de/gnozal/PureLVSORT_BETA.zip
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
						

