heya,
i am having some probs with scrolling in listview, i try to do this:
my listview has a list of (report mode):

=========================
1 | sfsd
2 | sdfsdf
3 | dsfsdsdf
4 | hgfhfh
5 | werewrw
6 | dfgdfgdf
..
..
1000 | etergdfgdf
============================

all i want to do is to scroll for example to the 465 line and select it (highlight it)
the LVM_SCROLL message doesn't give a good result for me, since it is quite bad.
mabye i can use the LVM_FINDITEM message but than how i highlight the item? (fullRowSelect).
thnx!
Posted on 2003-08-03 02:54:01 by wizzra
2 messages that should work for you:

LVM_ENSUREVISIBLE - lParam would be FALSE so the item if fully visible (not partially) and wParam is the index of the item you want to make "visible"

LVM_SETITEMSTATE - lParam a pointer to a LVITEM structure, you would set the state to LVIS_SELECTED, wParam is the index of the item to set...

Sorry, no code at the moment
Posted on 2003-08-03 07:07:09 by Gunner
the ensure visible seems to be fine, thnx
but selecting doesn't work, i tried do that in c:


LvItem.mask=LVIF_STATE;
LvItem.iItem=20;
LvItem.iSubItem=0;
LvItem.state=LVIS_SELECTED;
SendMessage(hList,LVM_ENSUREVISIBLE ,(WPARAM)20,FALSE); // Send to the Listview
//SendMessage(hList,LVM_SETITEMSTATE,(WPARAM)20,(LPARAM)&LvItem); // Send to the Listview
ListView_SetItemState(hList,20,LVIS_SELECTED,LVIF_STATE);


what seems to be the probb? the item isn't highlited in blue rect ;(
Posted on 2003-08-03 08:49:22 by wizzra
create your listview with LVS_SHOWSELALWAYS.

for ListView_SetItemState you have,

state = LVIS_SELECTED, good

mask = LVIF_STATE, not sure about this one, try LVIS_SELECTED for the mask and that should work
Posted on 2003-08-03 08:58:48 by Gunner
hi gunner, yeah you are right,



Select Item:
ListView_SetItemState(hList, -1, 0, LVIS_SELECTED); // deselect all items
SendMessage(hList,LVM_ENSUREVISIBLE ,(WPARAM)item,FALSE); // if item is far, scroll to it
ListView_SetItemState(hList,item,LVIS_SELECTED ,LVIS_SELECTED); // select item
ListView_SetItemState(hList,item,LVIS_FOCUSED ,LVIS_FOCUSED); // optional

Select All Item:
ListView_SetItemState(hList, -1, 0, LVIS_SELECTED); // deselect all items
ListView_SetItemState(hList,-1,LVIS_SELECTED ,LVIS_SELECTED);



this works fine =) :alright:
Posted on 2003-08-03 09:18:45 by wizzra
Gunner, wizzra

If I wanted to do this in MASM, would the following code accomplish the same thing?

My listview uses LVS_SHOWSELALWAYS, but the "selection" only appears if I hover the mouse pointer over the item.



;deselect all items
mov lvi.state, 0
mov lvi.stateMask, LVIS_SELECTED
invoke SendMessage, hList, LVM_SETITEMSTATE, -1, addr lvi
;select item 1
mov lvi.state, LVIS_SELECTED
mov lvi.stateMask, LVIS_SELECTED
invoke SendMessage, hList, LVM_SETITEMSTATE, 1, addr lvi


Thanks for any help!

farrier
Posted on 2003-08-05 03:12:25 by farrier
hm..try adding the EnsureVisible as well (if not scrolling)...
your code should work fine...
else try do as i do above and see iof it works
Posted on 2003-08-05 06:38:27 by wizzra
wizzra, Gunner

This worked better for me:



mov lvi.state, LVIS_SELECTED or LVIS_FOCUSED
mov lvi.stateMask, LVIS_SELECTED or LVIS_FOCUSED
invoke SendMessage, hList, LVM_SETITEMSTATE, 0, addr lvi


My first problem was not using

invoke SetFocus, hList

immediately after creating this ListView!:stupid: The selection only showed up if the mouse pointer was over the ListView, until it had focus

I was trying to enable the use of keyboard-only commands to make a ListView selection. If I just used the LVIS_SELECTED parameter, I would have to hit the up or down arrow keys 2 - 4 times before the selection would change from item to item.

Thanks for your help,

farrier
Posted on 2003-08-10 13:01:12 by farrier