I have a small problem with setting the programs window title according to what is selected in the listview. Here is what my code looks like:


;if select is pushed
.if  wParam==4002
xor eax,eax
mov editprocess,0
invoke SendMessage, , LVM_GETNEXTITEM, -1, LVNI_SELECTED ; Get currently selected item
mov lvi.iItem, eax
mov lvi.iSubItem, 0
mov lvi.imask, LVIF_PARAM
invoke  SendMessage, , LVM_GETITEM,0,addr lvi
mov lvi.iItem, eax
mov lvi.iSubItem, 0
mov lvi.imask, LVIF_TEXT
mov lvi.pszText,offset SelectProcessText
invoke SendMessage, , LVM_GETITEMTEXT,0,addr lvi
invoke  OpenProcess, PROCESS_ALL_ACCESS,NULL,lvi.lParam
        .if eax==NULL
      invoke MessageBox,hProcess,offset procnotfoundtxt,offset procnotfoundcap,MB_OK
      ret
      .else
      mov editprocess,eax
      invoke wsprintf,addr index,addr format2,addr SelectProcessText
      call SetTitle
      mov hProcess,0
    invoke DestroyWindow,hWin
.endif
.endif


then the SetTitle proc looks like this:


SetTitle PROC

invoke SetWindowText,hWnd,addr index
ret

SetTitle endp


The program lists all of the currently running processes so the user can select which one he/she would like to open. Once the process is selected, I want the name of the current process to be listed as the window title. Problem is, the code is not getting my current selection, but rather the first process listed. Any help is appreciated.

RIF
Posted on 2005-03-22 14:23:14 by resistance_is_futile
The problem is marked with ">"


invoke SendMessage, , LVM_GETNEXTITEM, -1, LVNI_SELECTED ; Get currently selected item
mov lvi.iItem, eax
mov lvi.iSubItem, 0
mov lvi.imask, LVIF_PARAM
invoke? SendMessage, , LVM_GETITEM,0,addr lvi
>>mov lvi.iItem, eax
>>mov lvi.iSubItem, 0
>>mov lvi.imask, LVIF_TEXT
>>mov lvi.pszText,offset SelectProcessText



After the LVM_GETITEM eax is TRUE for Successful. If you want the text of that item, all you need to do is use this bit of code:


invoke SendMessage, , LVM_GETNEXTITEM, -1, LVNI_SELECTED ; Get currently selected item
mov lvi.iItem, eax
mov lvi.iSubItem, 0
mov lvi.pszText,offset SelectProcessText
mov lvi.imask, LVIF_PARAM or LVIF_TEXT
invoke? SendMessage, , LVM_GETITEM,0,addr lvi


Cheers,
JC
Posted on 2005-03-22 14:48:21 by JimmyClif
thanks a bunch. Works perfect  :)
Posted on 2005-03-22 15:09:37 by resistance_is_futile