jj,
I am trying to get your Listview.asm working.
First time a proc - written by you - does not do it.
Any idea ?
Hi Clamicun,
The file you sent is not part of the MasmBasic package (http://masm32.com/board/index.php?topic=94.0). There was a short period about 5 years ago when I experimented with the "clear local variables" and "pop uses" macro. It was too complicated, and soon after I found a much better solution, which became the standard:
LvGetFiles proc uses edi esi FileMask
LOCAL lvi:LV_ITEM, sfi:SHFILEINFO, sPath[MAX_PATH]:BYTE
ClearLocals
Taken from \masm32\MasmBasic\Res\SkelWinLV.asc - that is the listview example that you see from menu Files/New Masm source.
When you type clv<Return> in RichMasm, ClearLocals gets inserted, and takes care of all your local variables, including structures and buffers. If you have big buffers and are worried about performance, check StackBuffer() (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1254).
HTH,
Jochen
Jochen jj,
thanks.
SkelWinLV.asc does work well - as always
jj,
trying to understand the comparefunction 'LvSbc' for invoke SendMessage, hList, LVM_SORTITEMS, eax, LvSbc.
There is one thing I definitely do not catch.
lvSort is the buffer - lvSortAsc db 20 dup(0)
??
lvSortAsc[edx] ;edx is the columnnumber
cmp lvSortAsc[edx], 0
Compare a "string" to 0 ?
It's not a string but a byte array:
lvSortAsc db MbMaxLvCols dup(0) ; max columns
There is often no real difference, but in this case it is an array of flags:
.if [ecx.NMHDR.code]==LVN_COLUMNCLICK
mov eax, [ecx.NM_LISTVIEW.iSubItem]
not lvSortAsc[eax] ; invert the flag
invoke SendMessage, hList, LVM_SORTITEMS, eax, LvSbc
...
cmp lvSortAsc[edx], 0
.if Zero?
neg eax ; reverse direction
.endif