Keeping VScroll.Value=VScroll.max 
Author Message
 Keeping VScroll.Value=VScroll.max

I have a picturebox to which I am writing lines.  I have a vertical
scrollbar to scroll through the visible lines.  For example, I may have 30
lines and the picture box displays any consecutive 30.  The vertical scroll
bar defines which 30 to display.  (Similar to simple word processing, such
as NotePad).

I then add a block of lines to the end, and I want to simultaneously scroll
to the end.  To do this I increase VScroll.Max by the number of lines added
and then I increase V.Scroll.Value to the new max.  The problem is that the
scroll bar first moves the bar up a little (when max is increased, because
the value is then less than max) and then moves it back to the bottom when
the value is set to the new max.

In Notepad, pasting lines continuously to the bottom does not cause this
scroll bar shudder.  The scrollbar stays in the max position, while the max
and the value are both incremented.

How does it do that?  How can I achieve the same with VB6's VScroll bar?

Any guidance would be appreciated.  Thanks.

Nigel



Fri, 07 Jan 2011 23:27:31 GMT  
 Keeping VScroll.Value=VScroll.max
This could be one way to solve your problem.
Paste this code in a form with a command button and a scrollbar, run the
code and you will see the scrollbar reset the position of the scroll button.
Un comment the two lines of code and you will not see the scroll bar reset
itself.

Ivar

Option Explicit
Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)
Private Declare Function LockWindowUpdate _
Lib "user32" (ByVal hwndLock As Long) As Long

Private Sub Command1_Click()
With VScroll1
'LockWindowUpdate .hWnd
.Max = 200
Sleep 500
.Value = 200
End With
'LockWindowUpdate 0&
End Sub



Fri, 07 Jan 2011 23:59:06 GMT  
 Keeping VScroll.Value=VScroll.max

Quote:

> This could be one way to solve your problem.
> Paste this code in a form with a command button and a scrollbar, run the
> code and you will see the scrollbar reset the position of the scroll button.
> Un comment the two lines of code and you will not see the scroll bar reset
> itself.

> Ivar

> Option Explicit
> Private Declare Sub Sleep Lib "kernel32" _
> (ByVal dwMilliseconds As Long)
> Private Declare Function LockWindowUpdate _
> Lib "user32" (ByVal hwndLock As Long) As Long

> Private Sub Command1_Click()
> With VScroll1
> 'LockWindowUpdate .hWnd
> .Max = 200
> Sleep 500
> .Value = 200
> End With
> 'LockWindowUpdate 0&
> End Sub

Fabulous!  This does the job perfectly.  Many thanks.

Nigel



Sat, 08 Jan 2011 00:36:42 GMT  
 Keeping VScroll.Value=VScroll.max


Quote:
> I then add a block of lines to the end, and I want to simultaneously scroll
> to the end.  To do this I increase VScroll.Max by the number of lines added
> and then I increase V.Scroll.Value to the new max.  The problem is that the
> scroll bar first moves the bar up a little (when max is increased, because
> the value is then less than max) and then moves it back to the bottom when
> the value is set to the new max.

> In Notepad, pasting lines continuously to the bottom does not cause this
> scroll bar shudder.  The scrollbar stays in the max position, while the max
> and the value are both incremented.

> How does it do that?  How can I achieve the same with VB6's VScroll bar?

> Any guidance would be appreciated.  Thanks.

For a quick fix, try this:

  With VScroll1
    .Visible = False
    .Max = .Max + Whatever
    .Value = .Max
    .Visible = True
  End With

LFS



Sat, 08 Jan 2011 00:48:32 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. VScroll Max Value

2. VSCROLL Max at 32,000

3. VSCROLL Max at 32,000

4. Capturing VScroll and WndProc

5. Help Creating a useful VScroll bar

6. VScroll-problem

7. Scroll Bars (vscroll) an over coming the 32K restriction

8. Strange VScroll

9. Vscroll VB5.0

10. Vscroll in listbox

11. Text box with vScroll in VB5

12. VScroll Event

 

 
Powered by phpBB® Forum Software