Home All Groups Group Topic Archive Search About

WebBrowser control not responding to SetScroll API

Author
21 Jul 2006 4:58 PM
iwdu15
hi, im trying to use APIs to set the scroll position of a WebBrowser control,
but it wont do anything, yet a textbox will....heres the code


    ' Scrollbar direction
    '
    Const SBS_HORZ = 0
    Const SBS_VERT = 1


    ' Windows Messages
    '
    Const WM_VSCROLL = &H115
    Const WM_HSCROLL = &H114
    Const SB_THUMBPOSITION = 4

    Private Declare Function GetScrollPos Lib "user32.dll" ( _
          ByVal hWnd As IntPtr, _
          ByVal nBar As Integer) As Integer

    Private Declare Function SetScrollPos Lib "user32.dll" ( _
        ByVal hWnd As IntPtr, _
        ByVal nBar As Integer, _
        ByVal nPos As Integer, _
        ByVal bRedraw As Boolean) As Integer

    Private Declare Function PostMessageA Lib "user32.dll" ( _
        ByVal hwnd As IntPtr, _
        ByVal wMsg As Integer, _
        ByVal wParam As Integer, _
        ByVal lParam As Integer) As Boolean


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

        Dim hwnd As IntPtr = Me.WebBrowser1.Handle

        Dim pos As Integer = GetScrollPos(hwnd, SBS_VERT) + 5

        If (SetScrollPos(hwnd, SBS_VERT, pos, True) <> -1) Then

            PostMessageA(hwnd, WM_VSCROLL, pos, Nothing)

            Else

            MsgBox("Can't set info (Err: " & GetLastWin32Error() & ")")

        End If

    End Sub

--
-iwdu15

Author
21 Jul 2006 6:42 PM
Herfried K. Wagner [MVP]
"iwdu15" <jmmgoalsteratyahoodotcom> schrieb:
> hi, im trying to use APIs to set the scroll position of a WebBrowser
> control,
> but it wont do anything, yet a textbox will....heres the code

Maybe the scrollbars are part of the default frame and not the control's
scrollbars.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
21 Jul 2006 8:23 PM
Tim Anderson
"iwdu15" <jmmgoalsteratyahoodotcom> wrote in message
news:704BB415-FABE-4672-8168-A5EF608F7385@microsoft.com...
> hi, im trying to use APIs to set the scroll position of a WebBrowser
> control,
> but it wont do anything, yet a textbox will....heres the code

Try using the HtmlWindow.ScrollTo method.

Tim
Free .NET HtmlEditor:
http://www.itwriting.com/htmleditor/index.php
Author
21 Jul 2006 8:51 PM
iwdu15
thanks, that works!
--
-iwdu15