SendMessage lParam empty

一个人想着一个人 提交于 2019-12-24 08:24:38

问题


I am trying to store a value in the lParam of a LV_ITEM:

;...
mov eax, value
mov lvi.lParam, eax
invoke SendMessage, hList, LVM_INSERTITEM, 0 addr lvi

lvi is a (LOCAL) LV_ITEM, and hList is the handle of my ListView Control. If this item is now clicked, i try to read it's value:

invoke SendMessage,hList,LVM_GETNEXTITEM,-1,LVNI_FOCUSED
mov lvi.iItem, eax
mov lvi.iSubItem, 0
mov lvi.imask, LVIF_TEXT
mov lvi.cchTextMax,256
invoke SendMessage,hList,LVM_GETITEM, 0, addr lvi

Again lvi is a (LOCAL) LV_ITEM, and hList the handle of the ListView. Now I can read e.g. the pszText (lvi.pszText), but the lParam is always zero. Last Error also returns zero.

Any help is appreciated


回答1:


Did you set the iMask of the LV_ITEM to LVIF_TEXT+LVIF_PARAM? If not, the lParam in the LV_ITEM structure is ignored.

;...
mov lvi.iMask, LVIF_TEXT+LVIF_PARAM
push value
pop lvi.lParam
invoke SendMessage, hList, LVM_INSERTITEM, 0 addr lvi

You will also need to request it in the same way:

invoke SendMessage,hList,LVM_GETNEXTITEM,-1,LVNI_FOCUSED
mov lvi.iItem, eax
mov lvi.iSubItem, 0
mov lvi.imask, LVIF_TEXT+LVIF_PARAM
mov lvi.cchTextMax,256
invoke SendMessage,hList,LVM_GETITEM, 0, addr lvi 


来源:https://stackoverflow.com/questions/3707516/sendmessage-lparam-empty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!