Jump to content
Sign in to follow this  
jcpetu

ListView Row number

Recommended Posts

jcpetu

Hi people,

I'm trying to implement ListView row number visualization in another ListView, but so far I'm stuck. Here the code, if someone could help I'll appreciate it.

 

#include <Array.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <GuiScrollBars.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>

Opt("GUIOnEventMode", 1)

Global $MainGui, $MsgOk, $MainGuiRefresh, $MainGuiLabelInfo

Global $MainGuiW = @DesktopWidth - 10, $MainGuiH = @DesktopHeight - 90

_GDIPlus_Startup()
Global $Notebook = _GDIPlus_BitmapCreateFromMemory(ScanNew32x32(), True) ;GDI bitmap
Global $Computer = _GDIPlus_BitmapCreateFromMemory(Computer32x32(), True) ;GDI bitmap
_GDIPlus_Shutdown()
;------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$MainGui = GUICreate("Test Sort", 800, 500, 10, 10, BitOR($GUI_SS_DEFAULT_GUI, $WS_CLIPSIBLINGS)) ;
GUISetOnEvent($GUI_EVENT_CLOSE, "EventsCtrl")

$MMenuLVAD = GUICtrlCreateListView("", 60, 82, 661, 321, -1, BitOR($LVS_EX_SUBITEMIMAGES, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
$hLVMMenu = GUICtrlGetHandle($MMenuLVAD);
GUICtrlSetOnEvent($MMenuLVAD, "_Setsort")
_GUICtrlListView_RegisterSortCallBack($MMenuLVAD)


$MMenuLVidx = GUICtrlCreateListView("#", 4, 82, 55, 321,  BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL))
_GUICtrlListView_SetExtendedListViewStyle(-1,BitOR($LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
$hLVidx = GUICtrlGetHandle($MMenuLVidx);
;_GUIScrollBars_ShowScrollBar($hLVidx, $SB_BOTH, False) ;not working !!!
;;------------------------------------------------------------------------------------------------------------------------------------------------------------------------

;Add columns
_GUICtrlListView_AddColumn($MMenuLVAD, "", 30)
_GUICtrlListView_AddColumn($MMenuLVAD, "Title 1", 80, 3)
_GUICtrlListView_AddColumn($MMenuLVAD, "Title 2", 80)
_GUICtrlListView_AddColumn($MMenuLVAD, "Title 3", 80)
_GUICtrlListView_AddColumn($MMenuLVAD, "Title 4", 80)

; Load images
Global $hImage = _GUIImageList_Create(32, 32, 5, 3)
_GUIImageList_Add($hImage, $Computer)
_GUIImageList_Add($hImage, $Notebook)
_GUIImageList_AddIcon($hImage, @SystemDir&"\"&"shell32.dll", 146)
 _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($MMenuLVAD, 0xff442211, 32, 32))

_GUICtrlListView_SetImageList($MMenuLVAD, $hImage, 1) ;   1 - Image list with small icons

GUISetState(@SW_SHOW)

For $i = 0 To 50
    _GUICtrlListView_AddItem($MMenuLVAD, "", 777) ;777 should be an index that not exists in the array
    _GUICtrlListView_AddSubItem($MMenuLVAD, $i, "Computer" & Random(13467, 23452, 1), 1, 0)
    _GUICtrlListView_AddSubItem($MMenuLVAD, $i, "User" & Random(100, 500, 1), 2, 1)
    _GUICtrlListView_AddSubItem($MMenuLVAD, $i, Random(25, 5000, 1), 3,2)
    _GUICtrlListView_AddSubItem($MMenuLVAD, $i, Random(1, 800, 1), 4,3)
_GUICtrlListView_AddItem($MMenuLVidx, $i + 1)
Next

$Recidx = _GUICtrlListView_GetItemRect($MMenuLVidx, 0)
$RecidxDim= $Recidx[3] - $Recidx[1]


While 1
    Sleep(10)
WEnd


Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $tNMHDR, $hWndFrom, $iCode
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hLVMMenu,$hLVidx
            ;This two lines to sincronize ListViewRowNumbers------------------------------------------------------------------
            Local $Lines = _SendMessage($hLVMMenu, $LVM_GETTOPINDEX) - _SendMessage($hLVidx, $LVM_GETTOPINDEX)
            _SendMessage($hLVidx, $LVM_SCROLL, 0, $Lines * $RecidxDim)
EndSwitch
EndFunc

Func _Setsort()
    _GUICtrlListView_SortItems($MMenuLVAD, GUICtrlGetState($MMenuLVAD))
EndFunc   ;==>_Setsort

Func EventsCtrl()
    Local $Msg = @GUI_CtrlId
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            _GUICtrlListView_UnRegisterSortCallBack($MMenuLVAD)
            _WinAPI_DeleteObject($Notebook)
            _WinAPI_DeleteObject($Computer)
            GUIDelete()
            Exit
    EndSwitch
EndFunc   ;==>EventsCtrl

Func ScanNew32x32()
    Local $ScanNew32x32png = 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3goUAQsnNhcJAQAACIhJREFUWMOtlklwHNUZx/+vt5lpzWg2SSNpLI0sC1k2XoSMwSCM7bCYShVlpTiQrTA4JLmEYCpJkVtcSVVOWZTKjUoAlUOASlIRwVV4iVFiULBiywvY1u4ZjUbbjGbt7untve4cjCkOkDCO+/IO3a9/v/5//b73CG7DNfzO8YOMsQHG2ABlDIwyUEZBKQOldJgyNvzcs4eGPmsu+X/Ax06eOsCYMyjLvo5IKASPJIE5Dmzbhm3bMEwTZUVBNreGiqKkKGOHf/z97711WwSOnTz1a0kUD3d2dED2eXF1chofnB+H6/GYVcKZLqV80GV1XevXIxoJo1QuIzmfhqbrg0d+9IMXbr6Hv1W4v67u8M67erGaW8NLf3yTcuFgZcfDewvp1tjsamPTSrUlkd+xtRcVtYqpiWtCUzjMNTc1Il8s7brngd2h9989feKWEjh28tQBjyQN775vF959bxTnpq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vQ3AOgCtAGIAqgAyAJIAFAAigFCsdR0rXy9fzDfo92qN/H2bdkjw8FOo2ENg7gLCdQqyJQ/yk0YhO2m8wUv2OQBUWFxcwNE3Zj4K1YfC4WBw9OXfDf2yf9/+hwF0AGgDsAbgOoAUgDOjIydyn7ECFj8ek5GYJzfzb+k7QSruETsnwiSyBN0wkV4uODOT9rWZ89pfi2k2VFi80Q3Jzv7+g4SIg5IoLrvgznwMSgOYBjA3OnKiWMtuyXsg3/+QuL37DvnBTd3CpmiYhAzLpQuL7sLktHX+wrj6fuoKPmnj/wG1Jc98TP5pLwAAAABJRU5ErkJggg=='
    Return Binary(_Base64Decode($ScanNew32x32png))
EndFunc   ;==>_ScanNew32x32png

Func Computer32x32() ;Original OK
    Local $Base64String = 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAHJElEQVR42s1Xa1CU1xl+vt3losDqslwUF1EakYtCDGY0SWupyeRHbDsJ40x+GNtqvf6o2kFTM0a8zBgFjBU0JHa8hEmmrXQ06WSIF8DlskSTWpOYcQi1Y2HIAMtV2F32/p2+53z7wccCNtOZjj0zh3POfmfO+7zP877nvEh4zE36vwXQ0tKidzqdJxwOR67YKEmia+fatbYxxkTXzsPXkZGRcnJy8sVpAdy6dWtlVVXVzfb2dgSDQeh0OtG5Me2oBcDHcEOyLE85BgIB7N271zMtAJvN9uPz58832JkRL79+bNw7lTSJz9kEMpmk7gkbmTLn3S8z3GpuhPfTSmzduhXSgwcPIuOMcYZgIBgcGRnxZWRksBADBWfOnLH2yEZsOFA66SCmWY99k5QRmj3a+Ygf6HDJ6LjdhMCnpxUAV69fc81LmTczNiaG6yI2Dg0Owmg0ori4GHY2G6+9WTLBYLgRLbCpjJPT6Bll6PMq/HV9RQCuhADcaGhgP1i4EHq9HvHx8ULvK1euoKCgAEVFRQTAhFffKBk/mH0Pw5rfvTLQ6ZDhDnLjkpCu524zgldPYcuWLZCabM1s0ROLIJPh2bNnw0/BcbW2DgU/fA67d++G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PSjMMjE9kXpREW5eIzSUueDajQ4Hz7E7cYG/OTlV1D1/vtwkiRxs4ycHf36da/J4aesWLHi+Z07d9ap5RZ/zom55+/cuXPj+zAhHT/5e7YwLY30N2POnGTofD50f3ETi176Oe7du4ceux2DQ4O8htMV7fqtYKCwsHBmSkrKk7Gxsbk5OTm/pr7c7/djeHgYvb29uH///t/sdvs5iou7/f39X1dXV49OC6D0xNtsvsUCC8UAl8Dn'
    $Base64String &= 'dMDxj1Yk5K9AX18f/tXRjp4eO4p27ZLWrl0blZ2dvXfNmjW/mTFjhlktPAcGBpT3IbTmr6paxNLbMlhTU/NOa2vrEQLinQTgWFmZMzkpKSZt/nyYzWZxHwh9iYkh8ryd4oBYcN396uu4eJPpDaqSjvDvqgHeeOao1TBPtRgq71RJ1Cq4vLz8zcuXL79FMTMhjkRW0xsQu/6Xvxj58s6XUovNhjiqB1evXs0vI/ZeZaWxq6vL+VR+vmTQ69dRpXyOvI9UDxbRJE8MDW25HmLBt5FaW1vbH0mmyQBoU7TBYEijcZHP5zNRirCIiIgBCqh/Uu8k/T18H2XBDCpWnyUpNq5ateo50t5CcaDnKaUa5WB4zU+sBCmGvqNb1Xbp0qULlF0tBMQzSYIp5uoYXt6rXunIc55fs8jwHGIvnQqZJAIWxxmh/6QcFDv27u7uBwS+h/aPUPfI4TRNAeC/aVJYVwGHV2qPPOCxtscO4N+zbf1+lKO2XAAAAABJRU5ErkJggg=='
    Return Binary(_WinAPI_Base64Decode($Base64String))
EndFunc   ;==>_Base64String

Func _Base64Decode($input_string)
    Local $struct = DllStructCreate("int")
    Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $input_string, "int", 0, "int", 1, "ptr", 0, "ptr", DllStructGetPtr($struct, 1), "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(1, 0, "")
    Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]")
    $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $input_string, "int", 0, "int", 1, "ptr", DllStructGetPtr($a), "ptr", DllStructGetPtr($struct, 1), "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($a, 1)
EndFunc   ;==>_Base64Decode

Func _WinAPI_Base64Decode($sB64String)
    Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "")
    Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]")
    $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($bBuffer, 1)
EndFunc   ;==>_WinAPI_Base64Decode

 

Share this post


Link to post
Share on other sites
spudw2k

I'm not sure what you are asking for exactly.  Can you describe what you mean by "implement ListView row number visualization in another ListView"?

Share this post


Link to post
Share on other sites
MikahS

Maybe this will help us understand, do you mean like the _ArrayDisplay function, how it displays a column of numbers for the rows?

ex:Capture.thumb.PNG.4ca5e650754aa4681a3247

 

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
UEZ

Try this:

 

#include <Array.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <GuiScrollBars.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>

Opt("GUIOnEventMode", 1)

Global $MainGui, $MsgOk, $MainGuiRefresh, $MainGuiLabelInfo

Global $MainGuiW = @DesktopWidth - 10, $MainGuiH = @DesktopHeight - 90

_GDIPlus_Startup()
Global $Notebook = _GDIPlus_BitmapCreateFromMemory(ScanNew32x32(), True) ;GDI bitmap
Global $Computer = _GDIPlus_BitmapCreateFromMemory(Computer32x32(), True) ;GDI bitmap
_GDIPlus_Shutdown()
;------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$MainGui = GUICreate("Test Sort", 800, 500, 10, 10, BitOR($GUI_SS_DEFAULT_GUI, $WS_CLIPSIBLINGS)) ;
GUISetOnEvent($GUI_EVENT_CLOSE, "EventsCtrl")

$MMenuLVAD = GUICtrlCreateListView("", 80, 82, 661, 321, -1, BitOR($LVS_EX_SUBITEMIMAGES, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
$hLVMMenu = GUICtrlGetHandle($MMenuLVAD);
GUICtrlSetOnEvent($MMenuLVAD, "_Setsort")
_GUICtrlListView_RegisterSortCallBack($MMenuLVAD)


$MMenuLVidx = GUICtrlCreateListView("", 4, 82, 76, 321,  BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL))
_GUICtrlListView_SetExtendedListViewStyle(-1,BitOR($LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_SUBITEMIMAGES))
$hLVidx = GUICtrlGetHandle($MMenuLVidx);
_GUICtrlListView_AddColumn($hLVidx, "#", 52, 1, -1)

;_GUIScrollBars_ShowScrollBar($hLVidx, $SB_BOTH, False) ;not working !!!
;;------------------------------------------------------------------------------------------------------------------------------------------------------------------------

;Add columns
_GUICtrlListView_AddColumn($MMenuLVAD, "", 30)
_GUICtrlListView_AddColumn($MMenuLVAD, "Title 1", 80, 3)
_GUICtrlListView_AddColumn($MMenuLVAD, "Title 2", 80)
_GUICtrlListView_AddColumn($MMenuLVAD, "Title 3", 80)
_GUICtrlListView_AddColumn($MMenuLVAD, "Title 4", 80)

; Load images
Global $hImage = _GUIImageList_Create(32, 32, 5, 3)
_GUIImageList_Add($hImage, $Computer)
_GUIImageList_Add($hImage, $Notebook)
_GUIImageList_AddIcon($hImage, @SystemDir&"\"&"shell32.dll", 146)
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($MMenuLVAD, 0xff442211, 32, 32))

_GUICtrlListView_SetImageList($MMenuLVAD, $hImage, 1) ;   1 - Image list with small icons
_GUICtrlListView_SetImageList($MMenuLVidx, $hImage, 1) ;   1 - Image list with small icons


For $i = 0 To 50
    _GUICtrlListView_AddItem($MMenuLVAD, "", 777) ;777 should be an index that not exists in the array
    _GUICtrlListView_AddSubItem($MMenuLVAD, $i, "Computer" & Random(13467, 23452, 1), 1, 0)
    _GUICtrlListView_AddSubItem($MMenuLVAD, $i, "User" & Random(100, 500, 1), 2, 1)
    _GUICtrlListView_AddSubItem($MMenuLVAD, $i, Random(25, 5000, 1), 3,2)
    _GUICtrlListView_AddSubItem($MMenuLVAD, $i, Random(1, 800, 1), 4,3)
    _GUICtrlListView_AddItem($MMenuLVidx, $i, 4)
Next

GUISetState(@SW_SHOW)

$Recidx = _GUICtrlListView_GetItemRect($MMenuLVidx, 0)
$RecidxDim1 = $Recidx[3] - $Recidx[1]

$Recidx = _GUICtrlListView_GetItemRect($MMenuLVAD, 0)
$RecidxDim2 = $Recidx[3] - $Recidx[1]

GUIRegisterMsg($WM_NOTIFY, "WM_Notify")

While 1
    Sleep(10)
WEnd


Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $tNMHDR, $hWndFrom, $iCode
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hLVMMenu
            ;This two lines to sincronize ListViewRowNumbers------------------------------------------------------------------
            Local $Lines = _SendMessage($hLVMMenu, $LVM_GETTOPINDEX) - _SendMessage($hLVidx, $LVM_GETTOPINDEX)
            _SendMessage($hLVidx, $LVM_SCROLL, 0, $Lines * $RecidxDim1)
            Return 0
        Case $hLVidx
            Local $Lines = _SendMessage($hLVidx, $LVM_GETTOPINDEX) - _SendMessage($hLVMMenu, $LVM_GETTOPINDEX)
            _SendMessage($hLVMMenu, $LVM_SCROLL, 0, $Lines * $RecidxDim2)
            Return 0
    EndSwitch
EndFunc

Func _Setsort()
    _GUICtrlListView_SortItems($MMenuLVAD, GUICtrlGetState($MMenuLVAD))
EndFunc   ;==>_Setsort

Func EventsCtrl()
    Local $Msg = @GUI_CtrlId
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            _GUICtrlListView_UnRegisterSortCallBack($MMenuLVAD)
            _WinAPI_DeleteObject($Notebook)
            _WinAPI_DeleteObject($Computer)
            GUIDelete()
            Exit
    EndSwitch
EndFunc   ;==>EventsCtrl

Func ScanNew32x32()
    Local $ScanNew32x32png = 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3goUAQsnNhcJAQAACIhJREFUWMOtlklwHNUZx/+vt5lpzWg2SSNpLI0sC1k2XoSMwSCM7bCYShVlpTiQrTA4JLmEYCpJkVtcSVVOWZTKjUoAlUOASlIRwVV4iVFiULBiywvY1u4ZjUbbjGbt7untve4cjCkOkDCO+/IO3a9/v/5//b73CG7DNfzO8YOMsQHG2ABlDIwyUEZBKQOldJgyNvzcs4eGPmsu+X/Ax06eOsCYMyjLvo5IKASPJIE5Dmzbhm3bMEwTZUVBNreGiqKkKGOHf/z97711WwSOnTz1a0kUD3d2dED2eXF1chofnB+H6/GYVcKZLqV80GV1XevXIxoJo1QuIzmfhqbrg0d+9IMXbr6Hv1W4v67u8M67erGaW8NLf3yTcuFgZcfDewvp1tjsamPTSrUlkd+xtRcVtYqpiWtCU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/h4LgPwqTzyFb/huXqGCzLx4yMlaquOJeWM/M5oadrw/+KvQ3AOgCtAGIAqgAyAJIAFAAigFCsdR0rXy9fzDfo92qN/H2bdkjw8FOo2ENg7gLCdQqyJQ/yk0YhO2m8wUv2OQBUWFxcwNE3Zj4K1YfC4WBw9OXfDf2yf9/+hwF0AGgDsAbgOoAUgDOjIydyn7ECFj8ek5GYJzfzb+k7QSruETsnwiSyBN0wkV4uODOT9rWZ89pfi2k2VFi80Q3Jzv7+g4SIg5IoLrvgznwMSgOYBjA3OnKiWMtuyXsg3/+QuL37DvnBTd3CpmiYhAzLpQuL7sLktHX+wrj6fuoKPmnj/wG1Jc98TP5pLwAAAABJRU5ErkJggg=='
    Return Binary(_Base64Decode($ScanNew32x32png))
EndFunc   ;==>_ScanNew32x32png

Func Computer32x32() ;Original OK
    Local $Base64String = 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAHJElEQVR42s1Xa1CU1xl+vt3losDqslwUF1EakYtCDGY0SWupyeRHbDsJ40x+GNtqvf6o2kFTM0a8zBgFjBU0JHa8hEmmrXQ06WSIF8DlskSTWpOYcQi1Y2HIAMtV2F32/p2+53z7wccCNtOZjj0zh3POfmfO+7zP877nvEh4zE36vwXQ0tKidzqdJxwOR67YKEmia+fatbYxxkTXzsPXkZGRcnJy8sVpAdy6dWtlVVXVzfb2dgSDQeh0OtG5Me2oBcDHcEOyLE85BgIB7N271zMtAJvN9uPz58832JkRL79+bNw7lTSJz9kEMpmk7gkbmTLn3S8z3GpuhPfTSmzduhXSgwcPIuOMcYZgIBgcGRnxZWRksBADBWfOnLH2yEZsOFA66SCmWY99k5QRmj3a+Ygf6HDJ6LjdhMCnpxUAV69fc81LmTczNiaG6yI2Dg0Owmg0ori4GHY2G6+9WTLBYLgRLbCpjJPT6Bll6PMq/HV9RQCuhADcaGhgP1i4EHq9HvHx8ULvK1euoKCgAEVFRQTAhFffKBk/mH0Pw5rfvTLQ6ZDhDnLjkpCu524zg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ERECC9iZs5sjIqK0lYg4tbs7OyMM5lM+drfh4aGblssFmd0dPSjMMjE9kXpREW5eIzSUueDajQ4Hz7E7cYG/OTlV1D1/vtwkiRxs4ycHf36da/J4aesWLHi+Z07d9ap5RZ/zom55+/cuXPj+zAhHT/5e7YwLY30N2POnGTofD50f3ETi176Oe7du4ceux2DQ4O8htMV7fqtYKCwsHBmSkrKk7Gxsbk5OTm/pr7c7/djeHgYvb29uH///t/sdvs5iou7/f39X1dXV49OC6D0xNtsvsUCC8UAl8Dn'
    $Base64String &= 'dMDxj1Yk5K9AX18f/tXRjp4eO4p27ZLWrl0blZ2dvXfNmjW/mTFjhlktPAcGBpT3IbTmr6paxNLbMlhTU/NOa2vrEQLinQTgWFmZMzkpKSZt/nyYzWZxHwh9iYkh8ryd4oBYcN396uu4eJPpDaqSjvDvqgHeeOao1TBPtRgq71RJ1Cq4vLz8zcuXL79FMTMhjkRW0xsQu/6Xvxj58s6XUovNhjiqB1evXs0vI/ZeZaWxq6vL+VR+vmTQ69dRpXyOvI9UDxbRJE8MDW25HmLBt5FaW1vbH0mmyQBoU7TBYEijcZHP5zNRirCIiIgBCqh/Uu8k/T18H2XBDCpWnyUpNq5ateo50t5CcaDnKaUa5WB4zU+sBCmGvqNb1Xbp0qULlF0tBMQzSYIp5uoYXt6rXunIc55fs8jwHGIvnQqZJAIWxxmh/6QcFDv27u7uBwS+h/aPUPfI4TRNAeC/aVJYVwGHV2qPPOCxtscO4N+zbf1+lKO2XAAAAABJRU5ErkJggg=='
    Return Binary(_WinAPI_Base64Decode($Base64String))
EndFunc   ;==>_Base64String

Func _Base64Decode($input_string)
    Local $struct = DllStructCreate("int")
    Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $input_string, "int", 0, "int", 1, "ptr", 0, "ptr", DllStructGetPtr($struct, 1), "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(1, 0, "")
    Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]")
    $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $input_string, "int", 0, "int", 1, "ptr", DllStructGetPtr($a), "ptr", DllStructGetPtr($struct, 1), "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($a, 1)
EndFunc   ;==>_Base64Decode

Func _WinAPI_Base64Decode($sB64String)
    Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "")
    Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]")
    $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($bBuffer, 1)
EndFunc   ;==>_WinAPI_Base64Decode

Currently I don't know to how to set the height of the cells in the left listview properly. I did it by adding also icons to the listview with the same size as in the right listview.

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
jcpetu

Uez, thanks a lot.

yes this is what I was trying to do.

is it possible to hide the scroll bars?

Share this post


Link to post
Share on other sites
UEZ

Which scrollbar exactly?


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
jcpetu

Both scrollbars of row listview, I attempeted to use without results:

_GUIScrollBars_ShowScrollBar($hLVidx, $SB_BOTH, False) ;not working !!!

Share this post


Link to post
Share on other sites
UEZ

Try this:

#include <Array.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <GuiScrollBars.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>

Opt("GUIOnEventMode", 1)

Global $MainGui, $MsgOk, $MainGuiRefresh, $MainGuiLabelInfo

Global $MainGuiW = @DesktopWidth - 10, $MainGuiH = @DesktopHeight - 90

_GDIPlus_Startup()
Global $Notebook = _GDIPlus_BitmapCreateFromMemory(ScanNew32x32(), True) ;GDI bitmap
Global $Computer = _GDIPlus_BitmapCreateFromMemory(Computer32x32(), True) ;GDI bitmap
_GDIPlus_Shutdown()
;------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$MainGui = GUICreate("Test Sort", 800, 500, 10, 10, BitOR($GUI_SS_DEFAULT_GUI, $WS_CLIPSIBLINGS)) ;
GUISetOnEvent($GUI_EVENT_CLOSE, "EventsCtrl")

$MMenuLVAD = GUICtrlCreateListView("", 80, 82, 661, 321, -1, BitOR($LVS_EX_SUBITEMIMAGES, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
$hLVMMenu = GUICtrlGetHandle($MMenuLVAD);
GUICtrlSetOnEvent($MMenuLVAD, "_Setsort")
_GUICtrlListView_RegisterSortCallBack($MMenuLVAD)


$MMenuLVidx = GUICtrlCreateListView("", 4, 82, 76, 321,  BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL))
_GUICtrlListView_SetExtendedListViewStyle(-1,BitOR($LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_SUBITEMIMAGES))
$hLVidx = GUICtrlGetHandle($MMenuLVidx);

$iDLLUser32 = DllOpen("user32.dll")
$wProcNewLV = DllCallbackRegister("_LVWndProc", "ptr", "hwnd;uint;wparam;lparam")
$wProcOldLV = _WinAPI_SetWindowLong($hLVMMenu, $GWL_WNDPROC, DllCallbackGetPtr($wProcNewLV))
$wProcOldLV2 = _WinAPI_SetWindowLong($hLVidx, $GWL_WNDPROC, DllCallbackGetPtr($wProcNewLV))


_GUICtrlListView_AddColumn($hLVidx, "#", 52, 1, -1)

;_GUIScrollBars_ShowScrollBar($hLVidx, $SB_BOTH, False) ;not working !!!
;;------------------------------------------------------------------------------------------------------------------------------------------------------------------------

;Add columns
_GUICtrlListView_AddColumn($MMenuLVAD, "", 30)
_GUICtrlListView_AddColumn($MMenuLVAD, "Title 1", 80, 3)
_GUICtrlListView_AddColumn($MMenuLVAD, "Title 2", 80)
_GUICtrlListView_AddColumn($MMenuLVAD, "Title 3", 80)
_GUICtrlListView_AddColumn($MMenuLVAD, "Title 4", 80)

; Load images
Global $hImage = _GUIImageList_Create(32, 32, 5, 3)
_GUIImageList_Add($hImage, $Computer)
_GUIImageList_Add($hImage, $Notebook)
_GUIImageList_AddIcon($hImage, @SystemDir&"\"&"shell32.dll", 146)
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($MMenuLVAD, 0xff442211, 32, 32))

_GUICtrlListView_SetImageList($MMenuLVAD, $hImage, 1) ;   1 - Image list with small icons
_GUICtrlListView_SetImageList($MMenuLVidx, $hImage, 1) ;   1 - Image list with small icons


For $i = 0 To 50
    _GUICtrlListView_AddItem($MMenuLVAD, "", 777) ;777 should be an index that not exists in the array
    _GUICtrlListView_AddSubItem($MMenuLVAD, $i, "Computer" & Random(13467, 23452, 1), 1, 0)
    _GUICtrlListView_AddSubItem($MMenuLVAD, $i, "User" & Random(100, 500, 1), 2, 1)
    _GUICtrlListView_AddSubItem($MMenuLVAD, $i, Random(25, 5000, 1), 3,2)
    _GUICtrlListView_AddSubItem($MMenuLVAD, $i, Random(1, 800, 1), 4,3)
    _GUICtrlListView_AddItem($MMenuLVidx, $i, 4)
Next

GUISetState(@SW_SHOW)

$Recidx = _GUICtrlListView_GetItemRect($MMenuLVidx, 0)
$RecidxDim1 = $Recidx[3] - $Recidx[1]

$Recidx = _GUICtrlListView_GetItemRect($MMenuLVAD, 0)
$RecidxDim2 = $Recidx[3] - $Recidx[1]

GUIRegisterMsg($WM_NOTIFY, "WM_Notify")

While 1
    Sleep(10)
WEnd


Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $tNMHDR, $hWndFrom, $iCode
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hLVMMenu
            ;This two lines to sincronize ListViewRowNumbers------------------------------------------------------------------
            Local $Lines = _SendMessage($hLVMMenu, $LVM_GETTOPINDEX) - _SendMessage($hLVidx, $LVM_GETTOPINDEX)
            _SendMessage($hLVidx, $LVM_SCROLL, 0, $Lines * $RecidxDim1)
            Return 0
        Case $hLVidx
            Local $Lines = _SendMessage($hLVidx, $LVM_GETTOPINDEX) - _SendMessage($hLVMMenu, $LVM_GETTOPINDEX)
            _SendMessage($hLVMMenu, $LVM_SCROLL, 0, $Lines * $RecidxDim2)
            Return 0
    EndSwitch
EndFunc

Func _LVWndProc($hWnd, $Msg, $wParam, $lParam)
    #forceref $hWnd, $Msg, $wParam, $lParam
    Switch $Msg
        Case $WM_NCCALCSIZE
            _RemoveVHScroll($hWnd)
        Case $WM_WINDOWPOSCHANGING
            Local $tWINDOWPOS = DllStructCreate($tagWINDOWPOS, $lParam)
            ;uncomment for mouse scrolling - no mouse scrolling without, but border is not erased (vertical key scrolling flickers visibly))
            DllStructSetData($tWINDOWPOS, "Flags", BitAND(DllStructGetData($tWINDOWPOS, "Flags"), BitNOT($SWP_FRAMECHANGED)))
    EndSwitch
    ;pass the unhandled messages to default WindowProc
    Local $aResult = DllCall($iDLLUser32, "lresult", "CallWindowProcW", "ptr", $wProcOldLV, "hwnd", $hWnd, "uint", $Msg, "wparam", $wParam, "lparam", $lParam)
    If @error Then Return -1
    Return $aResult[0]
EndFunc   ;==>_LVWndProc

Func _RemoveVHScroll($hWnd)
    Local $iLVStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
    $iLVStyle = BitAND($iLVStyle, BitNOT($WS_VSCROLL))
    $iLVStyle = BitAND($iLVStyle, BitNOT($WS_HSCROLL))
    _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $iLVStyle)
EndFunc   ;==>_RemoveVHScroll


Func _Setsort()
    _GUICtrlListView_SortItems($MMenuLVAD, GUICtrlGetState($MMenuLVAD))
EndFunc   ;==>_Setsort

Func EventsCtrl()
    Local $Msg = @GUI_CtrlId
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            If $wProcOldLV Then _WinAPI_SetWindowLong($hLVMMenu, $GWL_WNDPROC, $wProcOldLV)
            If $wProcOldLV2 Then _WinAPI_SetWindowLong($hLVidx, $GWL_WNDPROC, $wProcOldLV2)
            DllCallbackFree($wProcNewLV)
            GUIDelete($MainGui)
            DllClose($iDLLUser32)
            _GUICtrlListView_UnRegisterSortCallBack($MMenuLVAD)
            _WinAPI_DeleteObject($Notebook)
            _WinAPI_DeleteObject($Computer)
            Exit
    EndSwitch
EndFunc   ;==>EventsCtrl

Func ScanNew32x32()
    Local $ScanNew32x32png = 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3goUAQsnNhcJAQAACIhJREFUWMOtlklwHNUZx/+vt5lpzWg2SSNpLI0sC1k2XoSMwSCM7bCYShVlpTiQrTA4JLmEYCpJkVtcSVVOWZTKjUoAlUOASlIRwVV4iVFiULBiywvY1u4ZjUbbjGbt7untve4cjCkOkDCO+/IO3a9/v/5//b73CG7DNfzO8YO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QdQbw66WfWjxx3GGHsNkAwvKQZIoNsAj1ALv37ffB+AuAMsAlkZHTpg37wU6JerzmAh4TTT4OLQFIuCIB4QQeAURzUIQFAEEvTb8Hh1ekdTVB4KiUGPsEoAogOSn4QCgrVp5r2WXHGMZGe04xlbSaAvsQnvgUZStJBaUEaTVC1DMKQi6rnOGW/LZISLUUvPRkRPl/n37rwLo79+3nwEoAigAsFaXMtTMLM9ZnfmSYn8QWlDHUe/h4LgPwqTzyFb/huXqGCzLx4yMlaquOJeWM/M5oadrw/+KvQ3AOgCtAGIAqgAyAJIAFAAigFCsdR0rXy9fzDfo92qN/H2bdkjw8FOo2ENg7gLCdQqyJQ/yk0YhO2m8wUv2OQBUWFxcwNE3Zj4K1YfC4WBw9OXfDf2yf9/+hwF0AGgDsAbgOoAUgDOjIydyn7ECFj8ek5GYJzfzb+k7QSruETsnwiSyBN0wkV4uODOT9rWZ89pfi2k2VFi80Q3Jzv7+g4SIg5IoLrvgznwMSgOYBjA3OnKiWMtuyXsg3/+QuL37DvnBTd3CpmiYhAzLpQuL7sLktHX+wrj6fuoKPmnj/wG1Jc98TP5pLwAAAABJRU5ErkJggg=='
    Return Binary(_Base64Decode($ScanNew32x32png))
EndFunc   ;==>_ScanNew32x32png

Func Computer32x32() ;Original OK
    Local $Base64String = 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAHJElEQVR42s1Xa1CU1xl+vt3losDqslwUF1EakYtCDGY0SWupyeRHbDsJ40x+GNtqvf6o2kFTM0a8zBgFjBU0JHa8hEmmrXQ06WSIF8DlskSTWpOYcQi1Y2HIAMtV2F32/p2+53z7wccCNtOZjj0zh3POfmfO+7zP877nvEh4zE36vwXQ0tKidzqdJxwOR67YKEmia+fatbYxxkTXzsPXkZGRcnJy8sVpAdy6dWtlVVXVzfb2dgSDQeh0OtG5Me2oBcDHcEOyLE85BgIB7N271zMtAJvN9uPz58832JkRL79+bNw7lTSJz9kEMpmk7gkbmTLn3S8z3Gpuh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I_Base64Decode($Base64String))
EndFunc   ;==>_Base64String

Func _Base64Decode($input_string)
    Local $struct = DllStructCreate("int")
    Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $input_string, "int", 0, "int", 1, "ptr", 0, "ptr", DllStructGetPtr($struct, 1), "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(1, 0, "")
    Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]")
    $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $input_string, "int", 0, "int", 1, "ptr", DllStructGetPtr($a), "ptr", DllStructGetPtr($struct, 1), "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($a, 1)
EndFunc   ;==>_Base64Decode

Func _WinAPI_Base64Decode($sB64String)
    Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "")
    Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]")
    $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($bBuffer, 1)
EndFunc   ;==>_WinAPI_Base64Decode

 

I'm not sure whether I initialized the callback properly but it works for me. 


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
jcpetu

UEZ, Yes it works, as usual you are the guy.

THANKS a lot and have a good weekend.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • Broihon
      By Broihon
      Hey guys,

      I ran into a problem when I wanted to delete items of a listview using the delete key. My approach is to register my own WndProc for the listview and then filter the $WM_GETDLGCODE msg and then call the original WndProc.
      That works like a charm. The problem is that when the listview gets redrawn it somehow ends up in an infinite loop. The listview is suddenly emtpy and I can't interact with any controls of the GUI at all. Here's the code:
       
      #include <GUIConstantsEx.au3> #include <GUIListView.au3> #include <WinAPI.au3> $h_GUI = GUICreate("Test", 200, 200, 350, 350) $h_LV = GUICtrlCreateListView("Col 1|Col 2|Col 3", 0, 0, 200, 200) _GUICtrlListView_AddItem($h_LV, "") _GUICtrlListView_AddSubItem($h_LV, 0, "bla0", 0) _GUICtrlListView_AddSubItem($h_LV, 0, "bla0", 1) _GUICtrlListView_AddSubItem($h_LV, 0, "bla0", 2) _GUICtrlListView_AddItem($h_LV, "") _GUICtrlListView_AddSubItem($h_LV, 1, "bla1", 0) _GUICtrlListView_AddSubItem($h_LV, 1, "bla1", 1) _GUICtrlListView_AddSubItem($h_LV, 1, "bla1", 2) _GUICtrlListView_AddItem($h_LV, "") _GUICtrlListView_AddSubItem($h_LV, 2, "bla2", 0) _GUICtrlListView_AddSubItem($h_LV, 2, "bla2", 1) _GUICtrlListView_AddSubItem($h_LV, 2, "bla2", 2) _GUICtrlListView_AddItem($h_LV, "") _GUICtrlListView_AddSubItem($h_LV, 3, "bla3", 0) _GUICtrlListView_AddSubItem($h_LV, 3, "bla3", 1) _GUICtrlListView_AddSubItem($h_LV, 3, "bla3", 2) $h_LV_NewWndProc = DllCallbackRegister("WndProc_LV", "int", "hwnd;uint;wparam;lparam") $g_LV_OldWndProc = _WinAPI_SetWindowLong(GUICtrlGetHandle($h_LV), $GWL_WNDPROC, DllCallbackGetPtr($h_LV_NewWndProc)) GUISetState(@SW_SHOW) Func WndProc_LV($hWnd, $uMsg, $wParam, $lParam) Return _WinAPI_CallWindowProc($g_LV_OldWndProc, $hWnd, $uMsg, $wParam, $lParam) EndFunc ;==>WndProc_GUI Do Until GUIGetMsg() = $GUI_EVENT_CLOSE DllCallbackFree($h_LV_NewWndProc) As you can see I'm doing nothing in the WndProc of the listview. I'm simply calling the original WndProc. This still "freezes" when I mess with the width of the columns or in the original project when I add more items that they don't fit in the listview and I have to scroll. If I don't do that it's working fine.
    • c.haslam
      By c.haslam
      I have
      Local $idListview = GUICtrlCreateListView("",8,8,@DesktopWidth/2-16,@DesktopHeight-150,$LVS_SHOWSELALWAYS, _ $LVS_EX_INFOTIP) Local $hListView = GUICtrlGetHandle($idListview) _GUICtrlListView_InsertColumn($hListview, 0, "Filename", 400) _GUICtrlListView_InsertColumn($hListview, 1, "Ext", 50) _GUICtrlListView_InsertColumn($hListview, 2, "Size",70) _GUICtrlListView_InsertColumn($hListview, 3, 'Date time',100) _GUICtrlListView_InsertColumn($hListview, 4, "Path", 385) _GUICtrlListView_InsertColumn($hListview, 5, "sizeInt", 0) _GUICtrlListView_JustifyColumn($hListview, $kSize,1) ; right align then further on
      While True $sFnamExt = FileFindNextFile($iSrch) If @error Then ExitLoop EndIf $sAtts = FileGetAttrib($sPath&'\'&$sFnamExt) If StringInStr($sAtts,'D') Then If $sFnamExt<>'$RECYCLE.BIN' Then $sDirs &= '?'&$sPath&'\'&$sFnamExt EndIf Else $p = StringInStr($sFnamExt,'.',0,-1) ; last If $p=0 Then $sFnam = $sFnamExt $sExt = '' Else $sFnam = StringLeft($sFnamExt,$p-1) $sExt = StringTrimLeft($sFnamExt,$p) EndIf _GUICtrlListView_AddItem($hListview,$sFnam,-1,_GUICtrlListView_GetItemCount($hListview)+1000) _GUICtrlListView_AddSubItem($hListview,$nItem,$sExt,$kExt) $nSize = FileGetSize($sPath&'\'&$sFnamExt) $sSize = AddThousandsSeparator($nsize) _GUICtrlListView_AddSubItem($hListview,$nItem,$sSize,$kSize) _GUICtrlListView_AddSubItem($hListview,$nItem,$nsize,$kSizeInt) $nTotBytes += $nSize $a1 = FileGetTime($sPath&'\'&$sFnamExt,$FT_MODIFIED,$FT_ARRAY) $t = $a1[0]&'-'&$a1[1]&'-'&$a1[2]&' '&$a1[3]&':'&$a1[4] _GUICtrlListView_AddSubItem($hListview,$nItem,$t,$kDateTime) _GUICtrlListView_AddSubItem($hListview,$nItem,$sPath,$kPath) If $gSQL Then $s = "Insert into tbl values ("&_SQLite_Escape($sFnam)&","&_SQLite_Escape($sExt)&",'"& _ $sSize&"','"& _ $t&"',"&_SQLite_Escape($sPath)&","&$nSize&")" _SQLite_Exec(-1,$s) If @error Then MsgBox(0,@ScriptLineNumber,_SQLite_ErrMsg()) EndIf EndIf EndIf WEnd FileClose($iSrch) You will see that I heeded the advice in Help > _GUICtrlListView_AddItem: "As AutoIt uses the $iParam parameter to store the controlID of native-created ListView items, this value should be set sufficiently high for UDF-created items to avoid possible conflict with any existing controls - a starting value of 1000 is recommended."
      (It's unfortunate that the Example does not heed this advice. OK, it doesn't need to because there are no other controls, but still --- it would help neophytes if it did. Also to me _GUICtrlListView_AddItem is not native because it is a UDF. Confused?)
      My script then does a sort using SQLite, and updates the ListView:
      Local $hQuery Local $colNames = ['fnam','ext','nsize','dateTime','path','SizeInt'] Local $s = "Select * FROM tbl ORDER BY "&$colNames[$ncol]&';' _SQLite_Query(-1,$s, $hQuery) If @error Then MsgBox(0,@ScriptLineNumber,_SQLite_ErrMsg()) EndIf Local $aRow[$kSizeInt+1] Local $iItem=-1 While _SQLite_FetchData($hQuery, $aRow, False, False) = $SQLITE_OK ; Read Out the next Row If @error Then MsgBox(0,@ScriptLineNumber,_SQLite_ErrMsg()) EndIf $iItem += 1 For $i = $kFnam To $kSizeInt _GUICtrlListView_SetItem($hListview,$aRow[$i],$iItem,$i,Default) Next WEnd This works, but I had earlier coded
      _GUICtrlListView_SetItem($hListview,$aRow[$i],$iItem,$i,Default,$iItem+1000) because the same advice is in the Help for this function.
      So my care in specifying $param back-fired! What am I not understanding?
      The only difference in what works is that the $param parameter is defaulted.
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening everyone
      I am building a management for the company I work with, and I just imported a real amount of rows ( about 29000 ), in my SQLite DB.
      The thing I am not understanding, is the time that the script takes to build this amount of rows in the ListView.
      I didn't measure it, but I think it took 2 minutes or so to create each ListView item...
      It is normal that it takes so much time?
      What can I do to improve the creation of the items?

      Here's the code I am using to query and to create ListView items...
      ; Articles ListView: Global $lvwArticles = GUICtrlCreateListView("ID|Fornitore|Codice|Descrizione|EU|Prezzo|Sconto Applicato|Note", 14, 87, 1507, 660, BitOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_SORTASCENDING,$LVS_SORTDESCENDING), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT)) ; Query $strQuery = "SELECT * FROM ARTICOLI;" ; Query Execution _SQLite_GetTable2d($objDatabase, $strQuery, $arrResult, $intRows, $intColumns) If @error Then ; Error Handling Else ; Cleaning the ListView _GUICtrlListView_DeleteAllItems($lvwArticles) If @error Then ; Error Handling Else ; No records in the Table If UBound($arrResult) < 2 Then ; Error Handling Else _GUICtrlListView_BeginUpdate($lvwArticles) For $intCounter = 1 To UBound($arrResult) - 1 $strListViewItem = $arrResult[$intCounter][0] & "|" & _ $arrResult[$intCounter][1] & "|" & _ $arrResult[$intCounter][2] & "|" & _ $arrResult[$intCounter][3] & "|" & _ $arrResult[$intCounter][4] & "|" & _ $arrResult[$intCounter][5] & "|" & _ $arrResult[$intCounter][6] & "|" & _ $arrResult[$intCounter][7] $objListViewItem = GUICtrlCreateListViewItem($strListViewItem, $lvwArticles) Next _GUICtrlListView_EndUpdate($lvwArticles) EndIf EndIf EndIf Thanks in advance


      Best Regards.
    • Skysnake
      By Skysnake
      I am tracking this topic by @LarsJ.  It is very advanced and overkill for what I am currently trying to do.
       
      Problem is this.
      Listview contains columns, one of which is right aligned and gets populated by float values, such as 123.99.  Some do not have decimals ie 124.00 and on sort gets truncated to 124.  Its obviously still the same value, but the display has reset.
      ; line below is for list VIEW ;..................................0.........1......2............ $cListView = GUICtrlCreateListView("CUSTOMER|AMOUNT|DESCRIPTION", 8, 152, 764, 279) GUICtrlSetBkColor($cListView, $GUI_BKCOLOR_LV_ALTERNATE) ; alternate between the listview background color and the listview item background color GUICtrlSetBkColor($cListView, $LVStdClr) ; Set the background color for the listview _GUICtrlListView_SetColumnWidth($cListView, 0, 120) ; -- the client name _GUICtrlListView_SetColumnWidth($cListView, 1, 90) ;-- the amount _GUICtrlListView_JustifyColumn($cListView, 1, 1) ; 1 - Text is right aligned _GUICtrlListView_SetColumnWidth($cListView, 2, 200) ; the description What I am looking for is something native and simple like a 
          _GUICtrlListView_SetColumnFormat($cListView, 1, "%.2f") ;  1 - column is stringformatted to "%.2f"
      So that after each sort it will appear as it was in the original rendering.
      Is there something like this? I have not been able to find a simple solution.

      Thanks.
      Skysnake
    • Ambient
      By Ambient
      I have tried several way sto get this to work to no avail. Any help would be appreciated. #include <ListViewConstants.au3> #include <GuiListView.au3> #include "GuiListViewEx.au3" $idItem = GUICtrlCreateListViewItem($r & " | " & $c & $adoRs.Fields("TransactionAmount").value & " | " & $Timestamp & " | " & _StringProper($adoRs.Fields("Tillid").value) & @CRLF & @CRLF & "Card Number : " & $cardnum & " " , $idListView) ConsoleWrite( "IDITEM" & $idItem) If STRINGLEFT($adoRs.Fields("TransactionAmount").value,1)= "-" Then Consolewrite(" String is Negative" & @CRLF) ;Drops in Here as expected ;GUICtrlSetColor(-1, $COLOR_RED) ; Colour line if item is negative this didn' work $TxC= _GUICtrlListView_SetTextColor($hListView, $CLR_RED) ; I also tried $TxC= _GUICtrlListView_SetTextColor(-1, 0xFF0000) CONSOLEWRITE("TEXTCOLOUR RETURNED " & $TxC & @crlf) ; This is returning True ELSE Consolewrite(" String is NOT Negative" & @CRLF) EndIf  
×