The MASM Forum

General => The Campus => Topic started by: ragdog on August 15, 2016, 03:09:41 AM

Title: Sort listview
Post by: ragdog on August 15, 2016, 03:09:41 AM
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

Title: Re: Sort listview
Post by: fearless on August 15, 2016, 03:47:34 AM
or

Title: Re: Sort listview
Post by: jj2007 on August 15, 2016, 05:03:48 AM
You could do it sequentially:
- get folders
- sort them, append to listview
- get files
- sort & append.

Example:

include \masm32\MasmBasic\MasmBasic.inc      ; download (http://masm32.com/board/index.php?topic=94.0)
  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