home *** CD-ROM | disk | FTP | other *** search
/ Dan Appleman's Visual Bas…s Guide to the Win32 API / Dan.Applmans.Visual.Basic.5.0.Programmers.Guide.To.The.Win32.API.1997.Ziff-Davis.Press.CD / VB5PG32.mdf / classlib / classact / scroll.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-02-16  |  3.6 KB  |  93 lines

  1. VERSION 4.00
  2. Begin VB.Form frmScroll 
  3.    Caption         =   "Scrolling Example"
  4.    ClientHeight    =   2835
  5.    ClientLeft      =   2280
  6.    ClientTop       =   1995
  7.    ClientWidth     =   3975
  8.    ClipControls    =   0   'False
  9.    Height          =   3240
  10.    Left            =   2220
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   189
  13.    ScaleMode       =   3  'Pixel
  14.    ScaleWidth      =   265
  15.    Top             =   1650
  16.    Width           =   4095
  17.    Begin VB.CommandButton cmdScroll2 
  18.       Caption         =   "Scroll Window2"
  19.       Height          =   435
  20.       Left            =   2220
  21.       TabIndex        =   1
  22.       Top             =   720
  23.       Width           =   1395
  24.    End
  25.    Begin VB.CommandButton cmdScroll1 
  26.       Caption         =   "ScrollWindow"
  27.       Height          =   435
  28.       Left            =   2220
  29.       TabIndex        =   0
  30.       Top             =   120
  31.       Width           =   1395
  32.    End
  33. Attribute VB_Name = "frmScroll"
  34. Attribute VB_Creatable = False
  35. Attribute VB_Exposed = False
  36. Option Explicit
  37. '**********************************
  38. '**  Constant Definitions:
  39. '#If Win32 Then
  40. 'Private Const SW_ERASE& = &H4
  41. 'Private Const SW_INVALIDATE& = &H2
  42. 'Private Const SW_SCROLLCHILDREN = &H1
  43. '#End If 'WIN32
  44. '**********************************
  45. '**  Function Declarations:
  46. '#If Win32 Then
  47. 'Private Declare Function ScrollWindow Lib "user32" (ByVal hWnd As Long, ByVal XAmount As Long, ByVal YAmount As Long, lpRect As RECT, lpClipRect As RECT) As Long
  48. 'Private Declare Function ScrollWindowByNum& Lib "user32" Alias "ScrollWindow" (ByVal hWnd As Long, ByVal XAmount As Long, ByVal YAmount As Long, ByVal lpRect As Long, ByVal lpClipRect As Long)
  49. 'Private Declare Function ScrollWindowEx& Lib "user32" (ByVal hWnd As Long, ByVal dx As Long, ByVal dy As Long, lprcScroll As RECT, lprcClip As RECT, ByVal hrgnUpdate As Long, lprcUpdate As RECT, ByVal fuScroll As Long)
  50. 'Private Declare Function ScrollWindowExByNum& Lib "user32" Alias "ScrollWindowEx" (ByVal hWnd As Long, ByVal dx As Long, ByVal dy As Long, lprcScroll As RECT, lprcClip As RECT, ByVal hrgnUpdate As Long, ByVal lprcUpdate As Long, ByVal fuScroll As Long)
  51. 'Private Declare Function InflateRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
  52. 'Private Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
  53. 'Private Declare Function UpdateWindow& Lib "user32" (ByVal hWnd As Long)
  54. '#End If 'WIN32
  55. '**********************************
  56. '**  Type Definitions:
  57. '#If Win32 Then
  58. 'Private Type RECT
  59. '        left As Long
  60. '        top As Long
  61. '        right As Long
  62. '        bottom As Long
  63. 'End Type
  64. '#End If 'WIN32 Types
  65. Private m_Window As New foWindow
  66. Private Sub cmdScroll1_Click()
  67.     'dl& = ScrollWindowByNum&(Me.hWnd, 15, 10, 0, 0)
  68.     m_Window.Scroll 15, 10
  69. End Sub
  70. Private Sub cmdScroll2_Click()
  71.     Dim rc1 As foRectangle       'RECT
  72.     Dim rc2 As New foRectangle   'RECT
  73.     Dim dl&
  74.     ' Scroll the entire client area
  75.     'dl& = GetClientRect(Me.hWnd, rc1)
  76.     Set rc1 = m_Window.ClientRectangle
  77.     'LSet rc2 = rc1
  78.     rc1.Copy rc2
  79.     ' But specify a smaller clipping rectangle
  80.     'dl& = InflateRect(rc2, -30, -30)
  81.     rc2.Inflate -30, -30
  82.     ' Note how the controls don't move - but the image of them does!
  83.     'dl& = ScrollWindow&(Me.hWnd, 15, 10, rc1, rc2)
  84.     m_Window.Scroll 15, 10, rc1, rc2
  85. End Sub
  86. Private Sub Form_Load()
  87.     m_Window.Attach Me.hWnd
  88. End Sub
  89. ' Draw a line that
  90. Private Sub Form_Paint()
  91.     Line (20, 20)-(200, 200)
  92. End Sub
  93.