473,399 Members | 4,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

autoscroll

Hello,
if autoscroll is true in a form. Is there a way to detect the scrollbars are
active?
Thanks
Frank
Nov 21 '05 #1
5 3263
* "Frank" <fr***@frank.com> 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">The source of the event.</param>
''' <param name="e">
''' A <c>ScrollEventArgs</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>ScrollEventArgs</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(ScrollDirection.Horizontal))
ElseIf m.Msg = WM_VSCROLL Then
OnScroll(New ScrollEventArgs(ScrollDirection.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>ScrollEventArgs</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/>
Nov 21 '05 #2
I am not sure what you mean by by 'detect the scrollbars are active' but
here are two bits of info that might apply.

1. To determine if scroll bars are enabled test the form's AutoScroll
property.

If myForm.AutoScroll = True
MessageBox.Show("Scroll bars are active.")
End IF

2. To determine if the form has been scrolled from its original position
test the form's AutoScrollPosition.

If MyForm.AutoScrollPosition.X = 0 And MyForm.AutoScrollPostion.Y = 0 Then
MessageBox.Show("Form has been scrolled away from its base position.")
End If
--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com

"Frank" <fr***@frank.com> wrote in message
news:ch**********@news2.tilbu1.nb.home.nl...
Hello,
if autoscroll is true in a form. Is there a way to detect the scrollbars are active?
Thanks
Frank

Nov 21 '05 #3
Thanks Mike,
but this is not what I am looking for. Your test on 'autoscroll is true'
only shows that autoscrolling is enabled, not that the bars are actually
showing.
If no scrollbars are necessary they are not shown. If scrolling is needed,
autoscroll enabled will provide the bars automatically. I want to know
whether the bars are shown or not.
Regards
Frank

"Mike McIntyre [MVP]" <mi****@dotnetshowandtell.com> wrote in message
news:ex**************@tk2msftngp13.phx.gbl...
I am not sure what you mean by by 'detect the scrollbars are active' but
here are two bits of info that might apply.

1. To determine if scroll bars are enabled test the form's AutoScroll
property.

If myForm.AutoScroll = True
MessageBox.Show("Scroll bars are active.")
End IF

2. To determine if the form has been scrolled from its original position
test the form's AutoScrollPosition.

If MyForm.AutoScrollPosition.X = 0 And MyForm.AutoScrollPostion.Y = 0 Then
MessageBox.Show("Form has been scrolled away from its base position.")
End If
--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com

"Frank" <fr***@frank.com> wrote in message
news:ch**********@news2.tilbu1.nb.home.nl...
Hello,
if autoscroll is true in a form. Is there a way to detect the scrollbars

are
active?
Thanks
Frank


Nov 21 '05 #4
Herfried, thanks for the reply, but as far as I understand your coding it
only shows that the user is scrolling. I want to know whether the scrollbars
are actually shown, or that the formcontrols fit in the window and the
scrollbars are not visible (not needed).
I can't find a way and searching internet didn't provide an answer. I guess
I am the first having this problem.
Thanks
Frank
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2q************@uni-berlin.de...
* "Frank" <fr***@frank.com> 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">The source of the event.</param>
''' <param name="e">
''' A <c>ScrollEventArgs</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>ScrollEventArgs</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(ScrollDirection.Horizontal))
ElseIf m.Msg = WM_VSCROLL Then
OnScroll(New ScrollEventArgs(ScrollDirection.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>ScrollEventArgs</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/>

Nov 21 '05 #5
The solution is to use the HScroll and VScroll properties. From the
help...

---
Gets or sets a value indicating whether the horizontal scroll bar is
visible.
---

Unfortunately these are protected properties, so if you want to expose
them publicly you will need to subclass whatever it is you are using,
e.g. Form, UserControl, etc. and add in a new property that passes
through the protected value.

I checked it and it works. Now whether AutoScrollMinSize is the actual
size of the scrollbar is another matter :)

Colin Green
Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alexander Brown | last post by:
I have a custom control inside a frame. The frame has autoscroll set to true. The control has its dock set to Fill, and anchose set to top and left. If i scroll around the control using the...
0
by: Yasin Gedik | last post by:
Hello, I have a problem with autoscroll property. I am designing a form for pocket pc 2003 in whidbey, and deploying it to emulator. I set the forms Autoscroll property true and put...
1
by: John | last post by:
I'm trying to use the DrawText() method to draw some very long string text on the Panel with AutoScroll enabled. However, for some unknown reasons, I could not trigger the ScrollBar to show up. ...
0
by: amit bharadwaj | last post by:
hi all am using a panel , now i want to programitally set the thumb of autoscroll. for tht i have override wndproc() and try to set it .. ant it does .. but after that autoscroll too modify...
0
by: 23s | last post by:
I have 2 rich textboxes within an auto-scrolling panel object. The textboxes aren't wider than the panel, so it never scrolls horizontally. But the combined height of both textboxes is taller than...
0
by: Jeff | last post by:
I am making a custom control that displays images, allows zooming in and out, and can fit the image to the control. The way I am handling all of this is probably not best, but I was looking for a...
21
by: Sharon | last post by:
I have added an auto scroll feature to my DataGrid control like this: private void DoAutoScroll() { DataView dv = m_DataGrid.DataSource as DataView; DataGridCell cell = m_DataGrid.CurrentCell;...
0
by: eweaver | last post by:
Hello, I have a problem with getting an autoscrollbar to end up where I want it. Things to know about the prob: I have an imagebox inside of a Panel for (inheritance of) autoscroll capabilities....
1
by: =?Utf-8?B?R3VzIENodWNo?= | last post by:
I’m working on a GroupBox and need to set the AutoScroll property to true. My problem is I have no AutoScroll property listed in the property box. And even if I go in to the Designer.cs file I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.