how would i set the focus of an item in a listview?
I used the following but when you click on a different item the focus is not released.
mov flvi.flags, LVFI_STRING or LVFI_WRAP
lea eax, tmpString
mov flvi.psz, eax
INVOKE SendMessage, hList, LVM_FINDITEM, -1, addr flvi
cmp eax, -1
je @F
mov tNum, eax
mov flvi.flags, LVIS_FOCUSED or LVIS_SELECTED
INVOKE SendMessage, hList, LVM_SETITEMSTATE, tNum, addr flvi
Be sure to release the focus on the all items before setting it on a second...
mov D[lvi.state],0
mov D[lvi.stateMask],LVIS_SELECTED + LVIS_FOCUSED
// Release the focus
invoke SendMessage,[hListView],LVM_SETITEMSTATE,-1,offset lvi
mov D[lvi.state],LVIS_SELECTED + LVIS_FOCUSED
mov D[lvi.stateMask],LVIS_SELECTED + LVIS_FOCUSED
// Set the focus
invoke SendMessage,[hListView],LVM_SETITEMSTATE,[iItem],offset lvi
lol i did it on my own after a long time of forgetting setfocus.... here is what i used so it also will scroll to the item.
mov flvi.flags, LVFI_STRING or LVFI_WRAP
lea eax, tmpString
mov flvi.psz, eax
INVOKE SendMessage, hList, LVM_FINDITEM, -1, addr flvi
cmp eax, -1
je @F
mov tNum, eax
mov lvi.state, 0
invoke SendMessage, hList, LVM_SETITEMSTATE, -1, addr lvi
mov lvi.state, LVIS_FOCUSED or LVIS_SELECTED
mov lvi.stateMask, LVIS_FOCUSED or LVIS_SELECTED
invoke SendMessage, hList, LVM_SETITEMSTATE, tNum, addr lvi
invoke SendMessage, hList, LVM_ENSUREVISIBLE , tNum, TRUE
invoke SendMessage,hWnd,WM_CLOSE,NULL,NULL
invoke EndDialog,hWnd,NULL
mov hwndDlg,0
invoke SetFocus,hList
ret
Thanks tho as usual donkey