i cant see to work out a method to tell if my listview has anything in it. i have a toolbar button that when i press it, it deletes the entire contents of the listview but first verifies if the user wants to really delete with a yes or no message box. is what i would like to do is to first test if my listview has contents then if it does... "the would you like to clear the list view" message box will appear. if the listview is empty a message box will appear that says that the listview is empty and nothing can be deleted.

            .if ax == TB_CLEAR                    <-- if the clear toolbar button is pressed
                invoke MessageBoxEx,hWin,ADDR ClearListView,ADDR MessageBox1,MB_YESNO,0
                    .if eax == IDYES
                        invoke SendMessage,hListView,LVM_DELETEALLITEMS,0,0
                        invoke SetWindowText,hEditBox1,NULL
                        invoke SetWindowText,hEditBox2,NULL
                        invoke SetWindowText,hEditBox3,NULL
                        invoke SetWindowText,hEditBox4,NULL
Posted on 2001-05-14 00:52:00 by smurf
Hi Smurf, I wonder if you could use ListView_GetItem to retrieve the text of a list view item or subitem and check to see if there's actually anything there. Or maybe even better, use the LVM_GETITEMTEXT message explicitly as it returns the length of the retrieved string, then cmp it to zero. If some of your entries might be empty anyway, you might have to check them all though until you get one with text. Kayaker
Posted on 2001-05-14 02:05:00 by Kayaker
errr, how about LVM_GETITEMCOUNT? god bless msdn!
Posted on 2001-05-14 10:50:00 by fresh
i went through the msdn and definetly missed the getitemcout api. thanks for pointing that out fresh. kayaker i was setting up to use the getitemtext api but getitemcount is much more suitable for the job. thank you too for your reply. smurf
Posted on 2001-05-14 11:29:00 by smurf
im having a problem with LVM_GETITEMCOUNT. when i populate my listview with about 10 items or so LVM_GETITEMCOUNT on returns that i have 1 item. anyone know why this is. here is a code snipet im using to get the count and then put it in a textbox.
                invoke SendMessage,hListView,LVM_GETITEMCOUNT,0,0
                mov TotalItems,eax
                invoke SetWindowText,hEditBox1,ADDR TotalItems
Posted on 2001-05-15 07:26:00 by smurf
HI Smurf, I think the problem you have is cause by the result you get in EAX when calling LVM_GETITEMCOUNT.This result is in binary, you have to translate it to ascii. You can do something like this: invoke SendMessage,hListView,LVM_GETITEMCOUNT,0,0 mov ecx,1 .if eax > 9 mov ecx,2 .endif lea edi,TotalItems invoke CvDec invoke SetWindowText,hEditBox1,ADDR TotalItems ;This will translate the number in EAX to ascii in TotalItems CvDec PROC USES EBX ECX EDX EDI .IF ECX != 0 ;Just exit if null (bad) length. LEA EDI, ;Get EDI => past last digit in field. MOV EBX,10 ;Setup divisor. .REPEAT DEC EDI ;Point to previous ASCII slot, XOR EDX,EDX ;EDX:EAX = Dividend. .IF EAX != 0 ;Save bunch of cycles if no more to divide. DIV EBX ;EAX = EAX/10, EDX = remainder. .ENDIF OR DL,'0' ;Turn BCD digit to ASCII, MOV ,DL ;store ASCII digit, DEC ECX ;decrement loop count, .UNTIL ZERO? ;loop again if digit(s) left. .ENDIF RET CvDec ENDP
Posted on 2001-05-15 09:49:00 by Guy
thank you guy that was my problem. how did you know that the result would be returned in binary? the msdn didn't say anything about that! smurf
Posted on 2001-05-15 11:12:00 by smurf
Try the following code:

  ;On edit creation, get its dialog ID equivalent
  invoke GetDlgCtrlID, hEdit
  mov EditID, eax


  invoke SendMessage, hListView,LVM_GETITEMCOUNT,0,0
  invoke SetDlgItemInt, hWnd, EditID, eax, FALSE
If that gives you the correct answer, then your problem is because you aren't converting the return value from SendMessage correctly. Mirno
Posted on 2001-05-15 12:40:00 by Mirno
Smurf, All results from INVOKE are binary in EAX. Remember, computer' registers talk in binary, we have to translate it to ascii if we want to get the correct result. Regards, Guy
Posted on 2001-05-15 13:16:00 by Guy
.data fMtStrinG db "%lu",0 .data? buffer db 512 dup(?) TotalItems dd ? invoke SendMessage,hListView,LVM_GETITEMCOUNT,0,0 mov TotalItems,eax ;TotalItems is a dd not ascii invoke wsprintf,ADDR Buffer,ADDR fMtStrinG,TotalItems ;change to ascii invoke SetWindowText,hEditBox1,ADDR Buffer
Posted on 2001-05-15 18:20:00 by a nada