* "Frank" <fr***@frank.co m> scripsit:
if autoscroll is true in a form. Is there a way to detect the scrollbars are
You can base your implementation on this sample to intercept scrolling:
\\\
Imports System
Imports System.Windows. Forms
''' <summary>
''' Extends the panel control by a <c>Scroll</c> event.
''' </summary>
Public Class ScrollPanel
Inherits Panel
''' <summary>
''' Occurs when the panel is scrolled.
''' </summary>
''' <param name="sender">T he source of the event.</param>
''' <param name="e">
''' A <c>ScrollEventA rgs</c> that contains the event data.
''' </param>
Public Event Scroll(ByVal sender As Object, ByVal e As ScrollEventArgs )
Private Const WM_VSCROLL As Int32 = &H115
Private Const WM_HSCROLL As Int32 = &H114
''' <summary>
''' Raises the <c>Scroll</c> event.
''' </summary>
''' <param name="e">
''' A <c>ScrollEventA rgs</c> that contains the event data.
''' </param>
Protected Sub OnScroll(ByVal e As ScrollEventArgs )
RaiseEvent Scroll(Me, e)
End Sub
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_HSCROLL Then
OnScroll(New ScrollEventArgs (ScrollDirectio n.Horizontal))
ElseIf m.Msg = WM_VSCROLL Then
OnScroll(New ScrollEventArgs (ScrollDirectio n.Vertical))
End If
MyBase.WndProc( m)
End Sub
End Class
''' <summary>
''' Provides data for the <c>Scroll</c> event.
''' </summary>
Public Class ScrollEventArgs
Private m_Direction As ScrollDirection
''' <summary>
''' Creates a new instance of <c>ScrollEventA rgs</c>.
''' </summary>
Public Sub New(ByVal Direction As ScrollDirection )
Me.Direction = Direction
End Sub
''' <summary>
''' Gets or sets the direction the panel has been scrolled to.
''' </summary>
''' <value>The direction the panel has been scrolled to.</value>
Public Property Direction() As ScrollDirection
Get
Return m_Direction
End Get
Set(ByVal Value As ScrollDirection )
m_Direction = Value
End Set
End Property
End Class
''' <summary>
''' Provides possible scrolling directions.
''' </summary>
Public Enum ScrollDirection
''' <summary>
''' Horizontal scrolling.
''' </summary>
Horizontal
''' <summary>
''' Vertical scrolling.
''' </summary>
Vertical
End Enum
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>