PC Review


Reply
Thread Tools Rate Thread

How to determine that a scroll event occured

 
 
Lance
Guest
Posts: n/a
 
      16th Dec 2003
I need to know when the user scrolls a Windows.Forms.Panel
either by using one of the scroll buttons or by using one
of the scrollbars. Are there any events or overridable
methods that can be used to detect this?

Thanks,
Lance
 
Reply With Quote
 
 
 
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      16th Dec 2003
Hi,

Check to see if the autoscrollpostion has changed in the paint event
of the panel. Or create an inherited control. Override wndproc you will
recieve the WM_HSCROLL or WM_VSCROLL messages when the panel scrolls.
<ToolboxBitmap(GetType(Panel))> _

Public Class PanelScroll

Inherits System.Windows.Forms.Panel

Public Event Scroll(ByVal sender As Object, ByVal e As EventType)

Private Const WM_VSCROLL = &H115

Private Const WM_HSCROLL = &H114

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

Me.HorizontalScrollbar = True

'Add any initialization after the InitializeComponent() call

End Sub

'UserControl1 overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

components = New System.ComponentModel.Container

End Sub

#End Region

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

Dim Bytes, b As Byte()

If m.Msg = WM_VSCROLL Or m.Msg = WM_HSCROLL Then

RaiseEvent Scroll(Me, New EventArgs)

End If

MyBase.WndProc(m)

End Sub



End Class

Ken
-------------------------
"Lance" <(E-Mail Removed)> wrote in message
news:045901c3c427$849f8000$(E-Mail Removed)...
> I need to know when the user scrolls a Windows.Forms.Panel
> either by using one of the scroll buttons or by using one
> of the scrollbars. Are there any events or overridable
> methods that can be used to detect this?
>
> Thanks,
> Lance



 
Reply With Quote
 
Lance
Guest
Posts: n/a
 
      17th Dec 2003
Fantastic! Thanks a lot for the example.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to assign a custom task to an event that has not yet occured =?Utf-8?B?U29tYnJlU2lyZQ==?= Windows Vista Performance 0 8th Aug 2007 01:28 PM
HttpHandler detect which postback event occured =?Utf-8?B?ZGVib3JkZXI=?= Microsoft ASP .NET 2 21st Sep 2006 04:41 PM
How can I determine when scroll bars become visible for a form? Serg Microsoft Dot NET Framework Forms 4 1st Mar 2006 02:21 PM
In the worksheet_change event, how do I determine what occured? =?Utf-8?B?VGltIFBhdHRvbg==?= Microsoft Excel Worksheet Functions 6 3rd Nov 2005 08:38 PM
Determine when datagrid scroll bar is tapped Kreg Stanley Microsoft Dot NET Compact Framework 1 2nd Jan 2004 03:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:46 AM.