The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Grincheux on February 15, 2009, 04:41:17 PM

Title: Scrolling a listview programmatically
Post by: Grincheux on February 15, 2009, 04:41:17 PM
Hello !

My proc is analyzing items found in a listview.
I have to replace the text of the first colum by "Running"
The I run a small proc
When it returns I change "Running" by "Stoppped".
Then I get the next item
and the loop goes on

All of this is good and have no problem.

But if the listview can show 20 items on 200, I cannot see the 21st...
I wouldlike to scroll the listview but I did not find how to do it.

Here is my code :


@Loop :

lea edi,_Lvi
lea eax,_szServerName

mov (LVITEM Ptr [edi]).imask,LVIF_PARAM or LVIF_TEXT
mov (LVITEM Ptr [edi]).pszText,eax
mov (LVITEM Ptr [edi]).cchTextMax,SIZEOF _szTmp
mov (LVITEM Ptr [edi]).iItem,ebx
mov (LVITEM Ptr [edi]).iSubItem,0

INVOKE SendMessage,__hListView,LVM_GETITEM,0,edi
INVOKE Language_GetTextEx,26,_lpszTmp,SIZEOF _szTmp

mov (LVITEM Ptr [edi]).imask,LVIF_TEXT
mov (LVITEM Ptr [edi]).iSubItem,1
mov (LVITEM Ptr [edi]).pszText,eax

INVOKE SendMessage,__hListView,LVM_SETITEM,0,edi
INVOKE SendMessage,__hListView,LVM_ENSUREVISIBLE,0,0

mov (LVITEM Ptr [edi]).stateMask,LVIS_FOCUSED or LVIS_SELECTED
mov (LVITEM Ptr [edi]).state,LVIS_FOCUSED or LVIS_SELECTED

INVOKE SendMessage,__hListView,LVM_SETITEMSTATE,ebx,edi

INVOKE Analyse_Scrute,_lpszServerName

mov (LVITEM Ptr [edi]).stateMask,LVIS_FOCUSED or LVIS_SELECTED
mov (LVITEM Ptr [edi]).state,0

INVOKE SendMessage,__hListView,LVM_SETITEMSTATE,ebx,edi

INVOKE Language_GetTextEx,25,_lpszTmp,SIZEOF _szTmp

mov (LVITEM Ptr [edi]).iSubItem,1
mov (LVITEM Ptr [edi]).pszText,eax

INVOKE SendMessage,__hListView,LVM_SETITEM,0,edi

add ebx,1

INVOKE SendMessage,__hListView,LVM_GETITEMCOUNT,0,0

cmp ebx,eax
jle @Loop

xor ebx,ebx
jmp @Loop


Title: Re: Scrolling a listview programmatically
Post by: PBrennick on February 15, 2009, 05:28:39 PM
Grincheux,

ListView_EnsureVisible will do this for you. It will, if necessary, scroll the item into view.

Paul
Title: Re: Scrolling a listview programmatically
Post by: Grincheux on February 15, 2009, 07:56:16 PM
Thanks Paul,

I made an error while passing parameters.
I have corrected it and now it works fine.

Bye