Re: code to move the scroll bar of windows
- Posted by ghaberek (admin) Feb 28, 2013
- 1169 views
How do I move the scroll bar inside of a listView?
This scroll bar is automatically created by Windows, when the content is larger than the screen.
I tried setVScrollPos (ListView, nnn) and even setVScrollPos ({ListView,SB_VERT}, nnn)
But the first does nothing and the second gives error.
Please, any ideas?
I would not advise trying to manipulate the scroll bars of system-managed controls; who knows what wrath you may incur. It's best to send the LVM_ENSUREVISIBLE message to the ListView, which scrolls an row into view.
The LVM_ENSUREVISIBLE message is sent automatically by by Win32Lib when you call setIndex(), so you can just use that if it does the job.
However, setIndex() passes false (0) as the second parameter, which tells Windows that the item does not have to be entirely visible (just partially visible). In that case, you can use your own function to force its hand:
public procedure ensureVisible(integer id, integer index, integer entire=0) VOID = w32Func( xSendMessage, {getHandle(id), LVM_ENSUREVISIBLE, index-1, entire}) end procedure -- e.g. ensureVisible( myLV, index, 1 )
Hope this helps,
-Greg