How to enable PageDown, Pageup, PageLeft, PageRight region on scrollbars

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,<br/>
<br/>
I seem to remember a time when application scrollbars had clickable "scroll Page" buttons on them. What happened to them?<br/>
Do they still exist? If so, how do I make them visible?<br/>
<br/>
Ive written the code shown below to investigate the vertical scrollbar and it seems to indicate that a region is still defined for this function, but that it has been set to invisible (just paste code to Form1 code on a new WinForm project). Ive
searched for information on this but have come up empty handed.<br/>
<br/>
I know that I could implement this feature myself with additional controls, but I was just curious if it could be done using the existing framework.<br/>
<br/>
Any information will be greatly appreciated. <br/>
<br/>
<div style="border:1px solid #000080; color:#000000; font-family:Courier New,Courier,Monospace; font-size:10pt
<div style="background-color:#cef0f0; max-height:400px; overflow-y:scroll; padding:2px 5px; white-space:nowrap
<span style="color:#0000ff Imports System.Runtime.InteropServices<br/>
<br/>
<span style="color:#0000ff Public <span style="color:#0000ff Class Form1<br/>
<span style="color:#0000ff Friend p1 <span style="color:#0000ff
As <span style="color:#0000ff New Panel <span style="color:#0000ff
With {.Location = <span style="color:#0000ff New Point(5, 5), _<br/>
.Autoscroll =
<span style="color:#0000ff False, _<br/>
.Size =
<span style="color:#0000ff New Size(150, 200), _<br/>
.AutoSize =
<span style="color:#0000ff False, _<br/>
.BorderStyle = BorderStyle.FixedSingle _<br/>
}<br/>
<br/>
<span style="color:#0000ff Dim rtb1 <span style="color:#0000ff
As <span style="color:#0000ff New RichTextBox <span style="color:#0000ff
With {.Location = <span style="color:#0000ff New Point(160, 5), _<br/>
.Size =
<span style="color:#0000ff New Size(700, 200), _<br/>
.ScrollBars = RichTextBoxScrollBars.Vertical,
_<br/>
.ReadOnly =
<span style="color:#0000ff True, .WordWrap = <span style="color:#0000ff
False _<br/>
}<br/>
<br/>
<span style="color:#0000ff Private <span style="color:#0000ff
Sub Form1_Load(<span style="color:#0000ff ByVal sender <span style="color:#0000ff
As System.Object, <span style="color:#0000ff ByVal e <span style="color:#0000ff
As System.EventArgs) <span style="color:#0000ff Handles <span style="color:#0000ff
MyBase.Load<br/>
<span style="color:#0000ff Me.Font = <span style="color:#0000ff
New Font(<span style="color:#a31515 "Courier New", 10, FontStyle.Regular, GraphicsUnit.Point)<br/>
<br/>
<span style="color:#0000ff Dim b <span style="color:#0000ff
As <span style="color:#0000ff New Button <span style="color:#0000ff
With {.Height = 25, .Width = 100}<br/>
<span style="color:#0000ff For i <span style="color:#0000ff
As Int32 = 0 <span style="color:#0000ff To 199<br/>
b = <span style="color:#0000ff
New Button <span style="color:#0000ff With {.Location = <span style="color:#0000ff
New Point(1, i * (b.Height + 10)), _<br/>
.Width = b.Width, .Height = b.Height, _<br/>
.Text =
<span style="color:#a31515 "Button " & (i + 1).ToString}<br/>
p1.Controls.Add(b)<br/>
<span style="color:#0000ff Next i<br/>
<span style="color:#0000ff Me.Controls.AddRange(<span style="color:#0000ff New Control() {p1, rtb1})<br/>
<br/>
<span style="color:#0000ff With p1<br/>
.VerticalScroll.Visible = <span style="color:#0000ff
True : .VerticalScroll.Enabled = <span style="color:#0000ff True<br/>
.AutoScrollMinSize = .PreferredSize<br/>
<span style="color:#0000ff End <span style="color:#0000ff
With<br/>
<br/>
<span style="color:#0000ff Dim sbi <span style="color:#0000ff
As <span style="color:#0000ff New SCROLLBARINFO : sbi.cbSize = Marshal.SizeOf(sbi)<br/>
GetScrollBarInfo(<span style="color:#0000ff New HandleRef(p1, p1.Handle), IdObjects.OBJID_VSCROLL, sbi)<br/>
rtb1.AppendText(<span style="color:#a31515 "Base rgstate for ""p1"" indicates that the page up region is invisible." & vbCrLf)<br/>
<br/>
<span style="color:#0000ff Dim s <span style="color:#0000ff
As <span style="color:#0000ff String = <span style="color:#a31515
"" : <span style="color:#0000ff Dim [hex] <span style="color:#0000ff
As <span style="color:#0000ff String<br/>
<span style="color:#0000ff Dim fmt <span style="color:#0000ff
As <span style="color:#0000ff String = <span style="color:#a31515
" rgstate({0}): &H{1} [{2}] {3}"<br/>
<span style="color:#0000ff Dim state <span style="color:#0000ff
As <span style="color:#0000ff String<br/>
<span style="color:#0000ff Dim PadLeft, PadRight, Padding
<span style="color:#0000ff As Int32<br/>
<span style="color:#0000ff Dim PadLen
<span style="color:#0000ff As Int32 = 24<br/>
<span style="color:#0000ff For i <span style="color:#0000ff
As Int32 = 0 <span style="color:#0000ff To 5<br/>
<span style="color:#0000ff Select
<span style="color:#0000ff Case i<br/>
<span style="color:#0000ff Case 0 : s =
<span style="color:#a31515 "- The scroll bar itself."<br/>
<span style="color:#0000ff Case 1 : s =
<span style="color:#a31515 "- The top or right arrow button."<br/>
<span style="color:#0000ff Case 2 : s =
<span style="color:#a31515 "- The page up or page right region."<br/>
<span style="color:#0000ff Case 3 : s =
<span style="color:#a31515 "- The scroll box (thumb)."<br/>
<span style="color:#0000ff Case 4 : s =
<span style="color:#a31515 "- The page down or page left region."<br/>
<span style="color:#0000ff Case 5 : s =
<span style="color:#a31515 "- The bottom or left arrow button."<br/>
<span style="color:#0000ff End
<span style="color:#0000ff Select<br/>
<br/>
state = [Enum].GetName(<span style="color:#0000ff GetType(rgstate), sbi.rgstate(i))<br/>
Padding = PadLen - <span style="color:#0000ff
If(state <span style="color:#0000ff Is <span style="color:#0000ff
Nothing, 0, state.Length)<br/>
PadLeft = Padding 2 : PadRight = Padding - PadLeft<br/>
state = Space(PadLeft) & state & Space(PadRight)<br/>
[hex] = Microsoft.VisualBasic.Hex(sbi.rgstate(i))<br/>
[hex] = (Space(4 - hex.Length) & hex).Replace(<span style="color:#a31515 " ",
<span style="color:#a31515 "0")<br/>
rtb1.AppendText(<span style="color:#0000ff String.Format(fmt, i, [hex], state, s))<br/>
rtb1.AppendText(vbCrLf)<br/>
<span style="color:#0000ff Next i<br/>
<span style="color:#0000ff Me.AutoSize =
<span style="color:#0000ff False<br/>
<span style="color:#0000ff Me.Size = <span style="color:#0000ff
New Size(850, 250)<br/>
<br/>
<span style="color:#0000ff End <span style="color:#0000ff
Sub<br/>
<br/>
<DllImport(<span style="color:#a31515 "user32.dll", SetLastError:=<span style="color:#0000ff True, EntryPoint:=<span style="color:#a31515 "GetScrollBarInfo")> _<br/>
<span style="color:#0000ff Friend <span style="color:#0000ff
Shared <span style="color:#0000ff Function GetScrollBarInfo( _<br/>
<span style="color:#0000ff ByVal hWnd
<span style="color:#0000ff As HandleRef, <span style="color:#0000ff ByVal idObject
<span style="color:#0000ff As IdObjects, _<br/>
<span style="color:#0000ff ByRef psbi
<span style="color:#0000ff As SCROLLBARINFO) <span style="color:#0000ff
As <MarshalAs(UnmanagedType.Bool)> <span style="color:#0000ff Boolean<br/>
<span style="color:#0000ff End <span style="color:#0000ff
Function<br/>
<br/>
<span style="color:#0000ff Friend <span style="color:#0000ff
Enum IdObjects <span style="color:#0000ff As UInt32<br/>
OBJID_HSCROLL = &HFFFFFFFAL<br/>
OBJID_VSCROLL = &HFFFFFFFBL<br/>
OBJID_CLIENT = &HFFFFFFFCL<br/>
<span style="color:#0000ff End <span style="color:#0000ff
Enum<br/>
<br/>
<span style="color:#0000ff Friend <span style="color:#0000ff
Structure RECT<br/>
<span style="color:#0000ff Public Left
<span style="color:#0000ff As Int32 : <span style="color:#0000ff Public Top
<span style="color:#0000ff As Int32<br/>
<span style="color:#0000ff Public Right
<span style="color:#0000ff As Int32 : <span style="color:#0000ff Public Bottom
<span style="color:#0000ff As Int32<br/>
<span style="color:#0000ff Friend <span style="color:#0000ff
Function ToRectangle() <span style="color:#0000ff As Rectangle<br/>
<span style="color:#0000ff Return
<span style="color:#0000ff New Rectangle(<span style="color:#0000ff Me.Left,
<span style="color:#0000ff Me.Top, <span style="color:#0000ff Me.Right -
<span style="color:#0000ff Me.Left, <span style="color:#0000ff Me.Bottom -
<span style="color:#0000ff Me.Top)<br/>
<span style="color:#0000ff End <span style="color:#0000ff
Function<br/>
<span style="color:#0000ff End <span style="color:#0000ff
Structure<br/>
<br/>
<StructLayout(LayoutKind.Sequential)> _<br/>
<span style="color:#0000ff Friend <span style="color:#0000ff
Structure SCROLLBARINFO<br/>
<span style="color:#008000 <span style="color:#808080 <summary><span style="color:#008000 Specifies the size, in bytes, of the structure. Before calling the GetScrollBarInfo function, set cbSize to sizeof(SCROLLBARINFO).
<span style="color:#808080 </summary><br/>
<span style="color:#0000ff Friend cbSize
<span style="color:#0000ff As Int32<br/>
<span style="color:#008000 <span style="color:#808080 <summary><span style="color:#008000 Coordinates of the scroll bar as specified in a RECT structure.<span style="color:#808080 </summary><br/>
<span style="color:#0000ff Friend rcScrollBar
<span style="color:#0000ff As RECT<br/>
<span style="color:#008000 <span style="color:#808080 <summary><span style="color:#008000 Height or width of the thumb.<span style="color:#808080 </summary><br/>
<span style="color:#0000ff Friend dxyLineButton
<span style="color:#0000ff As Int32<br/>
<span style="color:#008000 <span style="color:#808080 <summary><span style="color:#008000 Position of the top or left of the thumb.<span style="color:#808080 </summary><br/>
<span style="color:#0000ff Friend xyThumbTop
<span style="color:#0000ff As Int32<br/>
<span style="color:#008000 <span style="color:#808080 <summary><span style="color:#008000 Position of the bottom or right of the thumb.
<span style="color:#808080 </summary><br/>
<span style="color:#0000ff Friend xyThumbBottom
<span style="color:#0000ff As Int32<br/>
<span style="color:#0000ff Friend reserved
<span style="color:#0000ff As Int32<br/>
<span style="color:#008000 <span style="color:#808080 <summary><span style="color:#008000 An array of DWORD elements. Each element indicates the state of a scroll bar component. The following values show the scroll
bar component that corresponds to each array index. <span style="color:#808080 </summary><br/>
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=6)> _<br/>
<span style="color:#0000ff Friend rgstate()
<span style="color:#0000ff As Int32<br/>
<span style="color:#008000 Index Scroll bar component<br/>
<span style="color:#008000 0 -- The scroll bar itself.<br/>
<span style="color:#008000 1 -- The top or right arrow button.<br/>
<span style="color:#008000 2 -- The page up or page right region.<br/>
<span style="color:#008000 3 -- The scroll box (thumb).<br/>
<span style="color:#008000 4 -- The page down or page left region.<br/>
<span style="color:#008000 5 -- The bottom or left arrow button.<br/>
<span style="color:#008000 The DWORD element for each scroll bar component can include a combination of the
<br/>
<span style="color:#008000 following bit flags.<br/>
<span style="color:#008000 Value Meaning<br/>
<span style="color:#008000 STATE_SYSTEM_INVISIBLE For the scroll bar itself, indicates the specified
<br/>
<span style="color:#008000 vertical or horizontal scroll bar does
not exist. <br/>
<span style="color:#008000 For the page up or page down regions,
indicates the <br/>
<span style="color:#008000 thumb is positioned such that the region
does not exist.<br/>
<span style="color:#008000 STATE_SYSTEM_OFFSCREEN For the scroll bar itself, indicates the window is sized
<br/>
<span style="color:#008000 such that the specified vertical or
horizontal scroll <br/>
<span style="color:#008000 bar is not currently displayed.<br/>
<span style="color:#008000 STATE_SYSTEM_PRESSED The arrow button or page region is pressed.<br/>
<span style="color:#008000 STATE_SYSTEM_UNAVAILABLE The component is disabled.<br/>
<span style="color:#0000ff End <span style="color:#0000ff
Structure<br/>
<br/>
<Flags()> _<br/>
<span style="color:#0000ff Friend <span style="color:#0000ff
Enum rgstate <span style="color:#0000ff As Int32<br/>
STATE_SYSTEM_UNAVAILABLE = &H1<br/>
STATE_SYSTEM_PRESSED = &H8<br/>
STATE_SYSTEM_INVISIBLE = &H8000<br/>
STATE_SYSTEM_OFFSCREEN = &H10000<br/>
<span style="color:#0000ff End <span style="color:#0000ff
Enum<br/>
<span style="color:#0000ff End <span style="color:#0000ff Class


View the full article
 
Back
Top