Author Topic: Listview by jj doesn't compile  (Read 186 times)

clamicun

  • Member
  • ***
  • Posts: 250
Listview by jj doesn't compile
« 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 ?

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7760
  • Assembler is fun ;-)
    • MasmBasic
Re: Listview by jj doesn't compile
« Reply #1 on: August 27, 2017, 01:26:55 PM »
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

  • Member
  • ***
  • Posts: 250
Re: Listview by jj doesn't compile
« Reply #2 on: August 27, 2017, 09:17:12 PM »
Jochen jj,
thanks.

SkelWinLV.asc  does work well - as always

clamicun

  • Member
  • ***
  • Posts: 250
Re: Listview by jj doesn't compile
« Reply #3 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 ?

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7760
  • Assembler is fun ;-)
    • MasmBasic
Re: Listview by jj doesn't compile
« Reply #4 on: August 28, 2017, 02:42:51 AM »
It's not a string but a byte array:
Code: [Select]
lvSortAsc db MbMaxLvCols dup(0) ; max columns
There is often no real difference, but in this case it is an array of flags:
Code: [Select]
.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