when the user doubleclicks the listview item (under ".if [edi.NMHDR].code == NM_DBLCLK"), my app has to insert a new item which is "1" under "a" column and "1" under "b" column into another listview (the down one). it seems simple, but it does not work as it has to.
pls help if u can.
app and source in the attachment.
hi,
what about this:
LOCAL lvhti:LV_HITTESTINFO
LOCAL pt:POINT
LOCAL buffer[256]:BYTE
LOCAL iSubItem:DWORD
....
.if [edi.NMHDR].code == NM_DBLCLK
; get item index
invoke GetCursorPos,ADDR pt
invoke ScreenToClient,[edi].NMHDR.hwndFrom,ADDR pt
m2m lvhti.pt.x,pt.x
m2m lvhti.pt.y,pt.y
invoke SendMessage,[edi].NMHDR.hwndFrom,LVM_HITTEST,0,ADDR lvhti
.if eax != -1
push esi
push edi
invoke SendDlgItemMessage,hDlg,IDC_LSV2,LVM_GETITEMCOUNT,0,0
mov esi,eax
mov lvi.imask,0
mov lvi.iItem,eax
mov lvi.iSubItem,0
invoke SendDlgItemMessage,hDlg,IDC_LSV2,LVM_INSERTITEM,0,ADDR lvi
; was a subtitem clicked?
invoke SendMessage,[edi].NMHDR.hwndFrom,LVM_GETCOLUMNWIDTH,0,0
.if pt.x < eax ;double-click in column 1
mov iSubItem,0
.else ;double-click in column 2
mov iSubItem,1
.endif
;shift all items in column down (by one)
mov edi,esi
sub edi,1
m2m lvi.iSubItem,iSubItem
.while SDWORD ptr edi >= 0
mov lvi.imask,LVIF_TEXT
mov lvi.iItem,edi
lea eax,buffer
mov lvi.pszText,eax
mov lvi.cchTextMax,SIZEOF buffer
invoke SendDlgItemMessage,hDlg,IDC_LSV2,LVM_GETITEM,0,ADDR lvi
mov lvi.iItem,esi
invoke SendDlgItemMessage,hDlg,IDC_LSV2,LVM_SETITEM,0,ADDR lvi
dec edi
dec esi
.endw
; set item at top
mov lvi.imask, LVIF_TEXT
mov lvi.iItem,0
mov lvi.pszText, offset strONE
invoke SendDlgItemMessage,hDlg,IDC_LSV2,LVM_SETITEM,0,ADDR lvi
pop edi
pop esi
.endif
.endif
regards, qWord
thx, but i think u misunderstood me. i just need to insert a new item with a subitem after the prevous one by incrementing the dwRow value which is used by lvi.iItem into second listview whenever the user doubleclicks on the first listview. the code u've offered is too complicated for such a simple action.
dwRow is a locale variable - declare it in .data-section
thanks a lot!! :bg
it works!