Board index » cppbuilder » using ListBox scroll position (again)

using ListBox scroll position (again)


2005-04-29 12:10:47 AM
cppbuilder33
Hi again!
I am still working on the scroll bar position in a TListBox.
The problem is when a component inside the List box is changed but is
not in the client area (it is hidden on the top of the list) the list
box automatiquely scrolls to the element which has the focus (also this
element is not displayed in the client area)
this works ->
SNDMSG( Form1->ListBox1->Handle, WM_VSCROLL, SB_BOTTOM, 0);
but this does not ->
SNDMSG( Form1->ListBox1->Handle, WM_VSCROLL, SB_THUMBPOSITION,
scrollPosBefore );
I get the scroll info by using
GetScrollInfo(Form1->ListBox1->Handle, SB_VERT, &si);
Am I doing something wrong in the second way?
Is there a good way to work around this?
thank you very much
Simon
 
 

Re:using ListBox scroll position (again)

Simon Guertin < XXXX@XXXXX.COM >wrote:
Quote

[...] The problem is when a component inside the List box is
changed but is not in the client area [...]
Try this:
SCROLLINFO si = { 0 };
// disable list box redraw
::SendMessage( ListBox1->Handle, WM_SETREDRAW, FALSE, 0 );
// get the scrollinfo
::GetScrollInfo( ListBox1->Handle, SB_VERT, &si );
// change the problematic component
// reset the scrollinfo
::SetScrollInfo( ListBox1->Handle, SB_VERT, &si, false );
// reenable redraw.
::SendMessage( ListBox1->Handle, WM_SETREDRAW, TRUE, 0 );
~ JD