Re: code to move the scroll bar of windows
- Posted by LarryMiller Feb 28, 2013
- 1117 views
Standard window messages and functions don't always work with Windows controls. Functions such as setVScrollPos work with windows because the default window procedure is designed to make them work. Windows controls have their own window procedure which does not support this. I have tried all such messages with Listview and other controls without success. I am sure that it could be done with some advanced methods but such solutions tend to be rather fragile and may break with later operating systems. Best avoided.
Unless you really need to scroll to a specific position the LVM_ENSUREVISIBLE message will be simplest and most reliable solution.
If you really must scroll to a specific position the only supported method is to use the LVM_SCROLL message. But be aware that this only allows scrolling relative to the current position. You can tell where that is using the LVM_GETTOPINDEX message (if you are using report view). Depending on what you want to do this could work.