News:

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

Main Menu

Listview by jj doesn't compile

Started by clamicun, August 27, 2017, 07:51:38 AM

Previous topic - Next topic

clamicun

jj,
I am trying to get your Listview.asm working.
First time a proc - written by you - does  not do it.

Any idea ?

jj2007

Hi Clamicun,

The file you sent is not part of the MasmBasic package. 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().

HTH,
Jochen

clamicun

Jochen jj,
thanks.

SkelWinLV.asc  does work well - as always

clamicun

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 ?

jj2007

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