News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Help with Listview Please

Started by JayPee, April 14, 2009, 03:09:01 AM

Previous topic - Next topic

JayPee

Hi all

I have a ListView dialog that I want to highlight a row by code rather than a mouse click, its part a a media player and I want the row that is playing to be highlighted.

Thanks
John
Greetings From New Zealand
(Land of the Long White Cloud)

Tedd

There doesn't appear to be a plain set-selection message (for list-view; for list-box it's simply lb_setcursel)..
Try LVM_SETSELECTIONMARK, if that's no good I think you'll have to resort to playing with LVM_SETITEM and set the currently-playing item's state to focussed+selected (and un-select the previous.)
Also, don't forget to LVM_SCROLL :wink
No snowflake in an avalanche feels responsible.

JayPee

Hi Ted

Thanks for your help -didn't work as I expected so have given it a rest for awhile lol

Regards
John
Greetings From New Zealand
(Land of the Long White Cloud)

gwapo


; I didn't wrote this, it's only taken from EnsureVisible disassembly.

EnsureVisible proc ListViewHandle:DWORD, ItemIndex:DWORD
   invoke SendMessage, ListViewHandle, 1013h, ItemIndex, 0
EnsureVisible endp


EDIT: Sorry the above code is just to ensure that the selection is visible (scrolled).

The question is how to select a list view item, here's how:

1. Get the item's LV_ITEM structure.
2. Set the structure's state to 2 (to mark it as SELECTED)
3. Set the structure's mask to 2 (to inform the ListView that the item should be shown as visibly selected)
4. Send the structure information to listview back: invoke SendMessage, hListView, 102bh, index, addr lviStruct
5. Finally, set the selection mark: invoke SendMessage, hListView, 1043h, 0, index

-c

JayPee

Hi
Thanks for that I will give it a try

Regards
John
Greetings From New Zealand
(Land of the Long White Cloud)

Jackal

Not sure if you figured this out but here is a piece of code from one of my apps. It allows someone to search a string in a listview and this will show it and highlight it when found.


       invoke GetDlgItemText, hWnd, 20, ADDR tmpString, 15
       cmp tmpString, NULL
       je Skip
       mov flvi.flags, LVFI_STRING or LVFI_WRAP or LVFI_PARTIAL
       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