Archive: Dynamically updating a listbox


Dynamically updating a listbox
  I have a listbox containing a dynamically generated list of items.

What I want to do is to delete a specific item in the list when a button is clicked. I have detected the button click and I can change text in textboxes using:

GetDlgItem $1 $hwnd 1201 ; field 2 (1200 + field 2 - 1)
SendMessage $1 ${WM_SETTEXT} 0 'STR:TextBoxUpdated'
abort

But this same method does not work for list boxes.
Any suggestions?


Use the message "LB_DELETESTRING" (To delete a string inside a ListBox) with "LB_FINDSTRINGEXACT" (To find the string inside a ListBox):

!define LB_DELETESTRING 0x0182

>!define LB_FINDSTRINGEXACT 0x01A2

>#$R0 = Control Handle
#$R1 = String to Delete

>System::Call "user32::SendMessageA(i R0, i ${LB_FINDSTRINGEXACT}, i '1', t R1) i.R1"
>System::Call "user32::SendMessageA(i R0, i ${LB_DELETESTRING}, i R1, n) i"

>StrCmp $R1 -1 0 +2
MessageBox MB_OK "Error: String not found."

Sweet - it worked like a charm - thanks