Click to See Complete Forum and Search --> : Scroll Scroll
hoa01206
August 14th, 2001, 09:36 AM
If you have two controls and each one has a vertical bar. Is there a way that when you scroll down or up on one the second follow the same trend.
Please, let me know if I can connect between the two scroll bars.
Thanks
Hisham
Iouri
August 14th, 2001, 10:36 AM
'this code will let you grab the scroll bar position.
'I did not try but I think you can set the second scroll bar tot the same position
Private Const SB_CTL = 2
Private Const SB_HORZ = 0
Private Const SB_VERT = 1
'
Private Declare Function GetScrollInfo Lib "user32" (ByVal hWnd As Long, ByVal n As Long, lpScrollInfo As SCROLLINFO) As Long
'
Private Type SCROLLINFO
cbSize As Long
fMask As Long
nMin As Long
nMax As Long
nPage As Long
nPos As Long
nTrackPos As Long
End Type
'
Private Const SIF_RANGE As Long = &H1
Private Const SIF_PAGE As Long = &H2
Private Const SIF_POS As Long = &H4
Private Const SIF_DISABLENOSCROLL As Long = &H8
Private Const SIF_TRACKPOS As Long = &H10
Private Const SIF_ALL As Long = (SIF_RANGE Or SIF_PAGE Or SIF_POS Or SIF_TRACKPOS)
'
Public Enum eScrollBar
sbHorizontal = 0
sbVertical = 1
End Enum
'
Public Function GetScrollBarPos(ByVal lHwnd As Long, ByVal ScrollBar As eScrollBar) As Long
'
Dim lFlag As Long
Dim sbInfo As SCROLLINFO
Dim lRet As Long
'
sbInfo.cbSize = Len(sbInfo)
sbInfo.fMask = SIF_POS
lFlag = ScrollBar
'
lRet = GetScrollInfo(lHwnd, lFlag, sbInfo)
'
If lRet > 0 Then ' ok
GetScrollBarPos = sbInfo.nPos
End If
'
End Function
Iouri Boutchkine
iouri@hotsheet.com
hoa01206
August 14th, 2001, 10:45 AM
Will this also work for a scroll bar that comes with the MSFlexGrid Control?
Thanks
Hisham
nicepat
September 27th, 2004, 04:44 PM
This is a great sample, but does not work on the Properties dialog box from Device Manager. Does anyone know why? It worked with other windows. I also have the correct hWnd value.....
:cry:
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.