News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Sort listview

Started by ragdog, August 15, 2016, 03:09:41 AM

Previous topic - Next topic

ragdog

Hello

I have a Listview with a imagelist 2 icons 0 for File 1 for Folder and fill this with FindfirstFile etc
How i can make all folders on top?

Example

.. < for jump back
Folder
Folder
Folder
Files
Files
.
etc


Have any an idea?


I have look on Radasm Project zipper but it use a Hidden Listbox but i think is not a good solution.

Mfg,
Raggy


fearless


       
  • lParam of listview item could be used to signify if its a file or a folder. TRUE/FALSE for folder or file instead, maybe used in combination with a custom sort using LVM_SORTITEMS perhaps?
or


       
  • if its just a explorer type listview thing, could do one loop using findfirstfile/nextfile of all files in folder that are a folder type, add these to listview, increment counter for total amount of entries added to listview, then do another loop in same folder but just look for entries that are files (as folders already processed previously) then add entries to listview adjusting counter for total items added to listview for this current folder contents.

jj2007

You could do it sequentially:
- get folders
- sort them, append to listview
- get files
- sort & append.

Example:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  GetFolders "\Masm32\Examples\exampl01\qikpad"
  SortFiles                  ; no args = most recent on top
  For_ ebx=0 To eax-1
      ; --- your add to listview code ---
      PrintLine Str$(GfSize(ebx)), Tb$, GfDate$(ebx), Spc2$, GfTime$(ebx), Tb$, Files$(ebx)
  Next
  GetFiles \Masm32\Examples\exampl01\qikpad\*.asm|*.inc            ; only asm or inc files
  SortFiles
  For_ ebx=0 To eax-1
      ; --- your add to listview code ---
      PrintLine Str$(GfSize(ebx)), Tb$, GfDate$(ebx), Spc2$, GfTime$(ebx), Tb$, Files$(ebx)
  Next
  Inkey "ok?"
EndOfCode

Output:
0       18.05.2015  22:02:57    \Masm32\Examples\exampl01\qikpad\24x24
0       16.05.2015  02:06:16    \Masm32\Examples\exampl01\qikpad\24x24\Unused_disabled
0       16.05.2015  02:05:34    \Masm32\Examples\exampl01\qikpad\24x24\Unused_hot
0       15.05.2015  13:06:29    \Masm32\Examples\exampl01\qikpad\Img
37023   18.05.2015  01:58:15    \Masm32\Examples\exampl01\qikpad\qikpadMenuEmbedded.asm
36985   18.05.2015  00:19:38    \Masm32\Examples\exampl01\qikpad\qikpadTTs.asm
2205    13.05.2015  20:11:55    \Masm32\Examples\exampl01\qikpad\tbmacrosJJ.asm
2948    13.05.2015  19:31:37    \Masm32\Examples\exampl01\qikpad\toolbarJJ.asm
2747    27.04.2008  13:24:50    \Masm32\Examples\exampl01\qikpad\qikpad.inc
16756   12.09.2005  16:05:44    \Masm32\Examples\exampl01\qikpad\qikpad.asm
2890    21.11.1999  12:39:48    \Masm32\Examples\exampl01\qikpad\toolbar.asm
971     11.10.1999  09:35:48    \Masm32\Examples\exampl01\qikpad\statusbr.asm
2065    09.10.1999  08:11:56    \Masm32\Examples\exampl01\qikpad\tbmacros.asm
2104    09.10.1999  08:11:56    \Masm32\Examples\exampl01\qikpad\filedlgs.asm