-
Mar 7th, 2012, 04:05 PM
#1
Thread Starter
PowerPoster
[VB6] - controlling a VB6 standard scrollbar
i have these code for get the scrollbar value property:
Code:
Option Explicit
Private PrevWin2 As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function SetScrollPos Lib "user32" (ByVal hwnd As Long, ByVal code As Long, ByVal nPos As Long, ByVal fRedraw As Boolean) As Long
Private Declare Function GetScrollPos Lib "user32" (ByVal hwnd As Long, ByVal nBar As Long) As Long
Const SB_HORZ = 0
Const SB_VERT = 1
Const SB_BOTH = 3
Private Const GWL_WNDPROC = (-4)
Public lngWndPicture1 As Long
Public lngWndVerticalScrollBar As Long
Public lngWndHorizontalScrollBar As Long
Public lngWndUserControl As Long
Private Function Proc2(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim s As Long
s = GetScrollPos(lngWndVerticalScrollBar, 1)
Debug.Print s
Proc2 = CallWindowProc(PrevWin2, hwnd, Msg, wParam, lParam)
End Function
Public Sub Hook2(Handle As Long)
'If PrevWin2 = 0 Then
PrevWin2 = SetWindowLong(Handle, GWL_WNDPROC, AddressOf Proc2)
'End If
End Sub
Public Sub Unhook2(Handle As Long)
'If PrevWin2 Then
Call SetWindowLong(Handle, GWL_WNDPROC, PrevWin2)
'PrevWin2 = 0
' End If
End Sub
and heres how i hook it:
Code:
If Ambient.UserMode = False Then
tmrIDEScrollClick.Enabled = True
lngWndVerticalScrollBar = ScrollingVertical.hwnd
Hook2 UserControl.ParentControls(0).hwnd
End If
how the debug value is always zero?
(i just need set and get the property Value on VB6 standard scrollbars)
-
Mar 7th, 2012, 05:20 PM
#2
Re: [VB6] - controlling a VB6 standard scrollbar
My guess is that UserControl.ParentControls(0) is not a scrollbar
What does the following return
Code:
Debug.Print TypeName(UserControl.ParentControls(0))
Also, you are not using the right constants in your call. You'll want to use SB_CTL (Const SB_CTL = 2), not 1. Review the MSDN documentation here
-
Mar 8th, 2012, 07:55 AM
#3
Thread Starter
PowerPoster
Re: [VB6] - controlling a VB6 standard scrollbar
Originally Posted by LaVolpe
My guess is that UserControl.ParentControls(0) is not a scrollbar
What does the following return
Code:
Debug.Print TypeName(UserControl.ParentControls(0))
Also, you are not using the right constants in your call. You'll want to use SB_CTL (Const SB_CTL = 2), not 1. Review the MSDN documentation here
isn't a scrollbar, that why i use a long variable
Code:
Public lngWndVerticalScrollBar As Long
but these api functions work with standar vb6 scrollbars?
-
Mar 8th, 2012, 02:30 PM
#4
Thread Starter
PowerPoster
Re: [VB6] - controlling a VB6 standard scrollbar
thanks now works. but i need ask anotherthing:
what scale mode i recive the results (because i recive a very big number)?
-
Mar 10th, 2012, 09:39 AM
#5
Thread Starter
PowerPoster
Re: [VB6] - controlling a VB6 standard scrollbar
ok... now i'm trying changing the scroll Value property, but i see 1 error(not error message):
Code:
GetScrollInfo lngWndVerticalScrollBar, 2, SI
If SI.nPos + 10 > SI.nMax Then
SetScrollPos lngWndVerticalScrollBar, 2, SI.nPos
Else
SetScrollPos lngWndVerticalScrollBar, 2, SI.nPos + 10
End If
what i see is that put it on position zero and don't scroll(don't call the change scroll event)
what can you advice me?
-
Mar 11th, 2012, 06:15 AM
#6
Thread Starter
PowerPoster
Re: [VB6] - controlling a VB6 standard scrollbar
i found my problem:
Code:
SI.cbSize = Len(SI)
SI.fMask = SIF_ALL
FlatSB_GetScrollInfo lngWndVerticalScrollBar, SB_CTL, SI
If SI.nPos - ScrollValue < SI.nMin Then
SI.nPos = SI.nMin
Else
SI.nPos = SI.nPos - ScrollValue
End If
FlatSB_SetScrollInfo lngWndVerticalScrollBar, SB_CTL, SI, True
now the pos button is moved normaly. but why the scrollbar change event isn't called?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|