Jump to content

_GUICtrlListView.au3


randallc
 Share

Recommended Posts

120 [correction] in zip includes comparing LVs to delete

_108; inbuilt DeleteDuplicates

0_97 faster remove dupes, arraydeletevbs

version to 0_80 now; July5th; Checkboxes and icon sort; exe incl, not image pics.

[lines needing Array2D.au3 remmed out (only needed for Win9x compat, and slower anyway)]

version to 0_57 now; June 15th; more complex [example working is Filebrowser below]

[NOte - needs Win2K at least for the DOS and maybe vbs commands...]

- Example with checkboxes

on toolbar

With tabs and calendar on toolbar [needs "slider.au3"]

Hi,

If you are frustrated by ListView;

1. Slow Sort [Can the register sort speed things up?; I cannot get it to...]

2. No Display of items over 4000

This may be for you. [10-100x times faster; the more items, the faster relatively; guaranteed <1sec unless over 4000 items ( starts to slow down) or using _GUIsetImage; still <4 secs instead of up to ?40!]

USAGE [** at present, only works for simple ListView report, ? not icons etc, can't modify.. etc]

A. Include"_GUICtrlListView.au3"

B. Change any previous script with these 7 functions;

1. GUICtrlSetImage, [** delete these; use "FileSetIconDefault " and then icons are automatic within limits; change limits with "$i_DefaultIconNumber=300" etc]

2.._GUICtrlListViewSort,

3..GUICtrlCreateListViewItem,

4..GUICtrlCreateListView

5..__FileListToArray

6.._FileSetIconDefault -** use this to add icons; see FileBrowser examplle; sppeds icon display; sets default icon by checking max number of filetypes in the list first; or set it yourself

7..__GUICtrlListViewDeleteAllItems

to add an extra underscore at the start;[ _GUICtrlSetImage],__GUICtrlListViewSort[so ends up with 2 underscores],_GUICtrlCreateListViewItem,_GUICtrlCreateListView

C. Run as usual

Let me know if it's useful, I'll add more functions

Best, Randall

EXAMPLES; cf icon sorting demo; default icon number shown 300; change by "$i_DefaultIconNumber=300" etc

[New func also "_GUIListViewClose()" if you will redraw the Listview in same running script - changed ; now included in new "__GUICtrlListViewDeleteAllItems "

;_GUICtrlListViewSorter.au3 0_12
#include-once
#include "_GUICtrlListView.au3"
;declares following; global $ar_LISTVIEW[4001],$ar_LISTVIEWArray[4001],$s_LISTVIEWSortOrder="ASC",$i_LISTVIEWNumItemsView,$i_LISTVIEWPrevcolumn=-1
;#opt('MustDeclareVars', 1)
Dim $searchGUI,$listview, $Btn_Exit, $msg, $Status, $Btn_Insert, $ret, $Input_Index,$timerstamp
$searchGUI = GUICreate("ListView Sort", 810, 623, (@DesktopWidth - 800) / 2, (@DesktopHeight - 600) / 2,$WS_MAXIMIZEBOX  + $WS_MINIMIZEBOX)
$listview = _GUICtrlCreateListView("col1|col2|col3", 10, 10, 790, 530, -1, BitOR($LVS_EX_REGIONAL, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
$timerstamp1 = TimerInit()

for $i=1 to 4000; it also works quicker over 4000, but starts slowing down as "_GUICtrlListViewInsertItem" used
    $s_RandomListItem="line"&Random(-10000, 10000, 1)&"|"&Random(-10000, 10000, 1)&"|more_"&Chr(Random(Asc("a"), Asc("z"), 1))&Chr(Random(Asc("a"), Asc("z"), 1))&String(Random(-10000, 10000, 1))
    _GUICtrlCreateListViewItem($s_RandomListItem, $listview)
next
ConsoleWrite("Time New :"&TimerDiff($timerstamp1) & " mseconds to search."&@lf)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
GUISetState()
Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($listview) ];only needed for slow  sort method
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            global $ar_LISTVIEW[1],$ar_LISTVIEWArray[1]; only if want to free memory at end, and scrip still running?
            ExitLoop
        Case $msg = $listview
            $i_Index=GUICtrlGetState($listview)
            ; sort the list by the column header clicked on
            $timerstamp1 = TimerInit()
            __GUICtrlListViewSort( $listview,$B_DESCENDING,$i_Index)
            $i_Time1=TimerDiff($timerstamp1)
            ;$timerstamp1 = TimerInit()
            ;_GUICtrlListViewSort($listview, $B_DESCENDING, GUICtrlGetState($listview))
            ;$i_Time2=TimerDiff($timerstamp1)
            ;ConsoleWrite("Time Trad :"&$i_Time2 & " mseconds to search."&@lf)
            ;__GUICtrlListViewSort( $listview,$B_DESCENDING,$i_Index)
            ;ConsoleWrite("Time New :"&$i_Time1 & " mseconds to search."&@lf)
            ;MsgBox(0,"","ratio :"&round($i_Time2/$i_Time1,2) & " ."&@lf&"TimeOld1="&round($i_Time2,2) & " ."&@lf&"TimeNEW="&round($i_Time1,2) & " ."&@lf,2)
            MsgBox(0,"","TimeNEW="&round($i_Time1,2) & " ."&@lf)
            ;ConsoleWrite("ratio :"&round($i_Time2/$i_Time1,2) & " ."&@lf)
    EndSelect
WEnd
Exit

Note - you do not need "Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($listview) ]", but still need to declare it "Local $B_DESCENDING", unless you are going to test against old sort.

Hi,

I think this is working on all international settings, with sliding toolbar, icons, and fast sort?...

So I have deleted versions I wrote which were not compatible...

Best, randall

GUICtrlListView.au3, ListView GUI Fast Sort

Edited by randallc
Link to comment
Share on other sites

  • Replies 59
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I've juste integrated in my "lastfilebrowser" program

and...simply amazing... the list not "clink" anymore while sorting

and it's fast, so fast !

i don't know how did you manage it, but i hope your functions will replace the old ones

good job man

c u

edit : your sort function doesn't work when list view is empty...i know i have to add

a work around, but it's just to inform

btw : it's only possible to pass by vbs (like some functions i've created too ?) ?

Edited by arcker

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

I've juste integrated in my "lastfilebrowser" program

Please remind me the link to your program?

your sort function doesn't work when list view is empty

OK, fixed in first post.

it's only possible to pass by vbs (like some functions i've created too ?)

I'd like to answer about the scripting control for vbs, but I am not sure of your question; you could write this file with AutoIt instead, but vbs gives the array sorting speed...

;_GUICtrlListViewSorter.au3 0_15
#include-once
#include "_GUICtrlListView.au3"
Dim $searchGUI,$listview, $Btn_Exit, $msg, $Status, $Btn_Insert, $ret, $Input_Index,$timerstamp
$searchGUI = GUICreate("ListView Sort", 810, 623, (@DesktopWidth - 800) / 2, (@DesktopHeight - 600) / 2,$WS_MAXIMIZEBOX  + $WS_MINIMIZEBOX)
$listview = _GUICtrlCreateListView("Index   |col1     |col2|col3", 10, 10, 790, 530,   $LVS_SHOWSELALWAYS, BitOR($LVS_EX_GRIDLINES, $LVS_EX_HEADERDRAGDROP, $LVS_EX_FULLROWSELECT, $LVS_EX_REGIONAL));Drag&Drop Columns
_GUICtrlSetImage($listview, "mmcndmgr.dll", 96)                   ;Set Icons for records
$timerstamp1 = TimerInit()
for $i=1 to 4000; it also works quicker over 4000, but starts slowing down as "_GUICtrlListViewInsertItem" used
    $s_RandomListItem=$i&"|line"&Random(-10000, 10000, 1)&"|"&Random(-10000, 10000, 1)&"|more_"&Chr(Random(Asc("a"), Asc("z"), 1))&Chr(Random(Asc("a"), Asc("z"), 1))&String(Random(-10000, 10000, 1))
    _GUICtrlCreateListViewItem($s_RandomListItem, $listview)
next
ConsoleWrite("Time New :"&TimerDiff($timerstamp1) & " mseconds to search."&@lf)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
GUISetState()
GUISetState(@SW_MAXIMIZE)
;Local $B_DESCENDING
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
        Case $msg = $listview
            $i_Index=GUICtrlGetState($listview)
            ; sort the list by the column header clicked on
            $timerstamp1 = TimerInit()
            __GUICtrlListViewSort( $listview,$B_DESCENDING,$i_Index)
            ConsoleWrite("Time New :"&round(TimerDiff($timerstamp1)) & " mseconds to search."&@lf)
            ;MsgBox(0,"","Time New :"&round(TimerDiff($timerstamp1)) & " mseconds to search."&@lf,1)
    EndSelect
WEnd

** I have added a 4th function, which slows down the display [if "_GUICtrlSetImage" has been called for icons] [still 5-10 x faster as uses fast vbs sort, but reverts to normal "ListViewdeleteAllItems [slow!]" and "GUICtrlCreateListViewItem"], of course, but should keep icons, etc OK/... please test and let me know; [EDIT - you will need to put your own routine for icons in the UDF, probably, depending on your program]

INSTRUCTION

As in first post; 4th func to change is "GUICtrlSetImage" to "_GUICtrlSetImage" by adding extra underscore at front

Best, Randall

Edited by randallc
Link to comment
Share on other sites

ok, i didn't that vbs array sort was faster, thanx you !

i've replace the old _guictrllistview.au3, and no more error while empty

my program is not yet released because i've a problem with the function _dateisvalid doesn't work (the example doesn't work too)

i will post it later

nice job

c u

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

Hi,

OK;

new version,

see running demo using icons in first post.

EXAMPLES; cf icon sorting demo; default icon number shown 300; change by "$i_DefaultIconNumber=300" etc

New func also "_GUIListViewClose()" if you will redraw the Listview in same running script

Best, randall

Link to comment
Share on other sites

Hi,

Some bugs fixed, and allowance for computers without "AM/PM" in time settings

version to 0_50 now; June 8th; more complex [example working is Filebrowser in first thread

Best, Randall

[Can I please have feedback as local regional date/time settings affect these functions]

Link to comment
Share on other sites

Think you should add some error handling when vbs in not properly installed or wrong version?

I got this error in SciTe when running Last File Browser whome uses your UDF's.

Z:\Code\autoit\include\_GUICtrlListView.au3 (442) : ==> The requested action with this object has failed.: 
$aArray= $vbs.run("FileListToArray",$sPath) 
$aArray= $vbs.run("FileListToArray",$sPath)^ ERROR

Othervice it looks cool so keep up the good work

Link to comment
Share on other sites

Think you should add some error handling when vbs in not properly installed or wrong version?

I got this error in SciTe when running Last File Browser whome uses your UDF's.

Z:\Code\autoit\include\_GUICtrlListView.au3 (442) : ==> The requested action with this object has failed.: 
$aArray= $vbs.run("FileListToArray",$sPath) 
$aArray= $vbs.run("FileListToArray",$sPath)^ ERROR

Othervice it looks cool so keep up the good work

Hi, Thanks for looking;

Last File Browser

in the first post of the thread you link to.. does not call that function; you must be using another file?

$aArray= $vbs.run("FileListToArray",$sPath)^ ERROR

That is usually the line which gives an error if I have the international date settings or time settings wrong; are you able to forward a copy of the DOS file you will have genearted please?

"FindFiles.txt" in your script directory?

error handling when vbs in not properly installed or wrong version

I agree, but would not now how to start...

Best, Randall

Link to comment
Share on other sites

Hi,

"norton says your filetoolbar.au3 "

"filetoolbar.au3" does not have any vbs until it runs and #includes "_GuiCtrlListView", so I'm not sure; does it complain on scannnig the file on the disc, or when it runs? [or do you mean the compiled version anyway?]

Thanks, Randall

Link to comment
Share on other sites

Hi,

Update on first post;

_GUICtrlListView.au3 ( 20.25k )

version to 0_57 now; June 15th; more complex [example working is Filebrowser below]lastfile_tabs.au3 ( 11.9k )

With tabs and calendar on toolbar [needs "slider.au3"]

Slider.au3 ( 3.36k ) Number of downloads: 0

Best, Randall
Link to comment
Share on other sites

simply amazing...

your version of lastfile is really cool, and works !

but one thing to consider : the CPU !

on my computer, the script consume 30% of my 2400+ ...

it's the toolbar that do this ? alone it's consume 2-3 %, and with the "autorefresh" , 30%

i'll try to add an option to desactivate this option, because it's too big, isn't it ?

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

the CPU !;on my computer, the script consume 30%

Thanks for looking; I am not computer-savvy enough to understand this;

on my current machine, the 31% is only for about 1/2sec or less, then back to 0-1%

Is taht what you mean? - Wouldn't you expect that for the amount of processing required for a refresh (reads the whole directory again, sorted by time, then selects that day's files from the lists)

All the other ways of doing this are slower that I can see; but a fair compromise would be to go back to "findnextfile" each time and sort the listview by time afterwards (x2); slower a little, and flickery [i had it running that way for a while... I'll tr to find the version for you to test if you like.];

What do you think?

randall

Link to comment
Share on other sites

@randallc

Hi here we meet again.

I see that you are making a lot of effort to increase the speed if the ListView handling.

As well as trying to break the 4000 Limit boundary. :D

I appreciate what you are doing, but I sorry to say that this is not quit the best approach.

I will post the a better way on doing ListView navigation, which has no limits and speed is no problem.

please comment on what you see.

regards,

Link to comment
Share on other sites

hey, i've just commented the other guilistview approach by p.trex

so, what is the best for our computers ? ^^

btw, on my computer, the script take 20-30% all the time ! not only at the start...

c u !

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

Hi,

[btw. - You'd need to ask @ptrex if he can apply it to this application?]

*** That's a worry about the cpu use staying at 30%!

I'll try it on another computer;

Is it...?

1. The new listView Gui approach.

2. Icons

3. Toolbar

4. Tabs?

Could you please try this one (back to sans toolbar, sans vbs[except for sort], sans DOS; just tabs , icons (you acn set the default icon manually for speed), and back to your "findfirstfile")

Best, Randall

[PS and the "old" version reverts to your original, without my GUIListView at all; still does 30% for 1/2 sec on refresh on my machine; ]

Edited by randallc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...