|
| GetScrollInfo and Set ScrollInfo Issues |
|
|
|
|
| Messages |
|
Related Types |
This message was discovered on microsoft.public.dotnet.languages.vb.
| Matthew Hazlett |
GetScrollInfo works but I can not get setScrollInfo to wrok, it reports Error 6 (Bad Handle). I use the same handle in GetScrollInfo as SetScrollInfo, any ideas?
Const SBS_HORZ = 0 Const SBS_VERT = 1 Const SIF_RANGE = 1 Const SIF_PAGE = 2 Const SIF_POS = 4 Const SIF_DISABLENOSCROLL = 8 Const SIF_TRACKPOS = 10 Const SIF_ALL = (SIF_RANGE Or SIF_PAGE Or SIF_POS Or SIF_TRACKPOS)
' Structure to hold info ' <StructLayout(LayoutKind.Sequential)> _ Public Structure SCROLLINFO Public cbSize As Integer Public fMask As Integer Public nMin As Integer Public nMax As Integer Public nPage As Integer Public nPos As Integer Public nTrackPos As Integer End Structure
' Imported Functions ' Private Declare Function GetScrollInfo Lib "user32.dll" ( _ ByVal hWnd As IntPtr, _ ByVal nBar As Integer, _ ByRef lpScrollInfo As SCROLLINFO) As Boolean
Private Declare Function SetScrollInfo Lib "user32.dll" ( _ ByVal hWnd As IntPtr, _ ByVal nBar As Long, _ ByVal lpScrollInfo As SCROLLINFO, _ ByVal fRedraw As Boolean) As Boolean
Private Function getScroll(ByVal hWnd As IntPtr) As SCROLLINFO Dim sc As New SCROLLINFO sc.fMask = SIF_ALL sc.cbSize = SizeOf(sc)
If GetScrollInfo(hWnd, SBS_VERT, sc) = False Then Throw New Exception("Can not get scroll info (Err: " & GetLastWin32Error() & ")") Else Console.WriteLine("Getting scroll info: Min=" & sc.nMin & " Max=" & sc.nMax & " Pos=" & sc.nPos) Return sc End If End Function
Private Sub scroll(ByVal hWnd As IntPtr, ByVal direction As Boolean) Dim sc As SCROLLINFO = getScroll(hWnd) sc.fMask = SIF_POS
If direction Then sc.nPos += 10 Else sc.nPos -= 10
Console.WriteLine("Setting scroll info: Min=" & sc.nMin & " Max=" & sc.nMax & " Pos=" & sc.nPos) If (Not SetScrollInfo(hWnd, SBS_VERT, sc, True)) Then MsgBox("Can't set info (Err: " & GetLastWin32Error() & ")") End If End Sub
|
|
|
| |
|
| |
| | |
|
|
|
|
|
|
|
BootFX
Reliable and powerful .NET application framework. |
|
|
|
|
|
|