Question

This issue has bugged me for some time - when attempting to scroll down a Panel the bar will not move until the mouse is released (doesn't seem to be a problem in other controls).

In this forum http://csharpcode25.appspot.com/question/5080f1624f1eba38a4ca86bf the user has experienced the same problem and a possible solution is given by overriding WndProc - not sure if something got lost in translation from C# to VB but it just throws an error 'Type of argument 'Number' is 'System.IntPtr', which is not numeric.' at the first line. Any ideas?

Thanks

Public Class Panelx
    Inherits Panel
    Private Const WM_HSCROLL As Integer = &H114
    Private Const WM_VSCROLL As Integer = &H115

    Protected Overrides Sub WndProc(ByRef m As Message)
        Try
            If (m.Msg = WM_HSCROLL OrElse m.Msg = WM_VSCROLL) AndAlso ((CInt(Fix(m.WParam)) And &HFFFF) = 5) Then
                ' Change SB_THUMBTRACK to SB_THUMBPOSITION
                m.WParam = CType((CInt(Fix(m.WParam)) And (Not &HFFFF)) Or 4, IntPtr)
            End If
            MyBase.WndProc(m)
        Catch ex As Exception
            EmailError(ex)
        End Try
    End Sub
End Class
Was it helpful?

Solution

Just remove the calls to the Fix() method:

If (m.Msg = WM_HSCROLL OrElse m.Msg = WM_VSCROLL) AndAlso ((CInt(m.WParam) And &HFFFF) = 5) Then
    ' Change SB_THUMBTRACK to SB_THUMBPOSITION
    m.WParam = CType((CInt(m.WParam) And (Not &HFFFF)) Or 4, IntPtr)
End If
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top