The MASM Forum

Projects => MasmBasic & the RichMasm IDE => Topic started by: clamicun on August 27, 2017, 07:51:38 AM

Title: Listview by jj doesn't compile
Post by: clamicun on August 27, 2017, 07:51:38 AM
jj,
I am trying to get your Listview.asm working.
First time a proc - written by you - does  not do it.

Any idea ?
Title: Re: Listview by jj doesn't compile
Post by: jj2007 on August 27, 2017, 01:26:55 PM
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
Title: Re: Listview by jj doesn't compile
Post by: clamicun on August 27, 2017, 09:17:12 PM
Jochen jj,
thanks.

SkelWinLV.asc  does work well - as always
Title: Re: Listview by jj doesn't compile
Post by: clamicun on August 28, 2017, 12:20:58 AM
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 ?
Title: Re: Listview by jj doesn't compile
Post by: jj2007 on August 28, 2017, 02:42:51 AM
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