home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / mwheel / DATATEST.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-02-13  |  5.9 KB  |  189 lines

  1. VERSION 5.00
  2. Object = "{94C8DA1F-FDF5-11D0-BB7C-0055003B26DE}#1.0#0"; "mwheel.ocx"
  3. Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
  4. Begin VB.Form Form1 
  5.    Caption         =   "Data Control and Grid test"
  6.    ClientHeight    =   2970
  7.    ClientLeft      =   2145
  8.    ClientTop       =   3045
  9.    ClientWidth     =   5355
  10.    LinkTopic       =   "Form1"
  11.    PaletteMode     =   1  'UseZOrder
  12.    ScaleHeight     =   2970
  13.    ScaleWidth      =   5355
  14.    Begin MSDBGrid.DBGrid DBGrid1 
  15.       Bindings        =   "datatest.frx":0000
  16.       Height          =   1275
  17.       Left            =   60
  18.       OleObjectBlob   =   "datatest.frx":0010
  19.       TabIndex        =   6
  20.       Top             =   1200
  21.       Width           =   5235
  22.    End
  23.    Begin MouseWheelOCX.MouseWheel MouseWheel1 
  24.       Left            =   4680
  25.       Top             =   180
  26.       _ExtentX        =   847
  27.       _ExtentY        =   847
  28.    End
  29.    Begin VB.CommandButton cmdMoveLast 
  30.       Caption         =   "MoveLast"
  31.       Height          =   315
  32.       Left            =   4020
  33.       TabIndex        =   5
  34.       Top             =   840
  35.       Width           =   1275
  36.    End
  37.    Begin VB.CommandButton cmdMovePrev 
  38.       Caption         =   "MovePrevious"
  39.       Height          =   315
  40.       Left            =   2700
  41.       TabIndex        =   4
  42.       Top             =   840
  43.       Width           =   1275
  44.    End
  45.    Begin VB.CommandButton cmdMoveNext 
  46.       Caption         =   "MoveNext"
  47.       Height          =   315
  48.       Left            =   1380
  49.       TabIndex        =   3
  50.       Top             =   840
  51.       Width           =   1275
  52.    End
  53.    Begin VB.CommandButton cmdMoveFirst 
  54.       Caption         =   "MoveFirst"
  55.       Height          =   315
  56.       Left            =   60
  57.       TabIndex        =   2
  58.       Top             =   840
  59.       Width           =   1275
  60.    End
  61.    Begin VB.Data Data1 
  62.       Caption         =   "Spin the MouseWheel over me or the grid!"
  63.       Connect         =   "Access"
  64.       DatabaseName    =   "F:\Code\Controls\MouseWheel\TechSupport\DataControl\Test.mdb"
  65.       DefaultCursorType=   0  'DefaultCursor
  66.       DefaultType     =   2  'UseODBC
  67.       Exclusive       =   0   'False
  68.       Height          =   345
  69.       Left            =   60
  70.       Options         =   0
  71.       ReadOnly        =   0   'False
  72.       RecordsetType   =   1  'Dynaset
  73.       RecordSource    =   "Sys Info"
  74.       Top             =   2520
  75.       Width           =   5235
  76.    End
  77.    Begin VB.Label Label2 
  78.       BorderStyle     =   1  'Fixed Single
  79.       Caption         =   "Label2"
  80.       DataField       =   "Value"
  81.       DataSource      =   "Data1"
  82.       Height          =   255
  83.       Left            =   60
  84.       TabIndex        =   1
  85.       Top             =   480
  86.       Width           =   5235
  87.    End
  88.    Begin VB.Label Label1 
  89.       BorderStyle     =   1  'Fixed Single
  90.       Caption         =   "Label1"
  91.       DataField       =   "Name"
  92.       DataSource      =   "Data1"
  93.       Height          =   255
  94.       Left            =   60
  95.       TabIndex        =   0
  96.       Top             =   120
  97.       Width           =   5235
  98.    End
  99. Attribute VB_Name = "Form1"
  100. Attribute VB_GlobalNameSpace = False
  101. Attribute VB_Creatable = False
  102. Attribute VB_PredeclaredId = True
  103. Attribute VB_Exposed = False
  104. Option Explicit
  105. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
  106. Private Enum RepositionTypes
  107.    MoveFirst = 0
  108.    MoveLast = 1
  109.    MoveNext = 2
  110.    MovePrev = 3
  111. End Enum
  112. Private m_hWndData As Long
  113. Private Sub cmdMoveFirst_Click()
  114.    Reposition MoveFirst
  115. End Sub
  116. Private Sub cmdMoveLast_Click()
  117.    Reposition MoveLast
  118. End Sub
  119. Private Sub cmdMoveNext_Click()
  120.    Reposition MoveNext
  121. End Sub
  122. Private Sub cmdMovePrev_Click()
  123.    Reposition MovePrev
  124. End Sub
  125. Private Sub Form_Activate()
  126.    Dim col As Column
  127.    For Each col In DBGrid1.Columns
  128.       col.Width = DBGrid1.Width \ 2
  129.    Next col
  130. End Sub
  131. Private Sub Form_Load()
  132.    MouseWheel1.ScrollWhich = ControlUnderMouse
  133.    Data1.DatabaseName = App.Path & "\test.mdb"
  134.    m_hWndData = FindWindowEx(Me.hWnd, 0, "ThunderData", Data1.Caption)
  135.    Me.Icon = Nothing
  136. End Sub
  137. Private Sub Reposition(ByVal WhereTo As RepositionTypes)
  138.    With Data1.Recordset
  139.       Select Case WhereTo
  140.          Case MoveFirst
  141.             .MoveFirst
  142.          Case MoveLast
  143.             .MoveLast
  144.          Case MoveNext
  145.             If .EOF = False Then
  146.                .MoveNext
  147.                ' to mimick the EOFAction property of the data control
  148.                If .EOF = True Then
  149.                   .MoveLast
  150.                End If
  151.             End If
  152.          Case MovePrev
  153.             If .BOF = False Then
  154.                .MovePrevious
  155.                ' to mimick the BOFAction property of the data control
  156.                If .BOF = True Then
  157.                   .MoveFirst
  158.                End If
  159.             End If
  160.       End Select
  161.    End With
  162. End Sub
  163. Private Sub MouseWheel1_AfterMouseWheel(ByVal hWnd As Long, ByVal Delta As Long, ByVal Shift As Long, ByVal Button As Long, ByVal x As Long, ByVal y As Long)
  164.    If hWnd = m_hWndData Then
  165.       If Delta > 0 Then
  166.          If Button And vbMiddleButton Then
  167.             Reposition MoveFirst
  168.          Else
  169.             Reposition MovePrev
  170.          End If
  171.       Else
  172.          If Button And vbMiddleButton Then
  173.             Reposition MoveLast
  174.          Else
  175.             Reposition MoveNext
  176.          End If
  177.       End If
  178.    End If
  179. End Sub
  180. Private Sub MouseWheel1_BeforeMouseWheel(ByVal hWnd As Long, ByVal Delta As Long, ByVal Shift As Long, ByVal Button As Long, ByVal x As Long, ByVal y As Long, Cancel As Boolean)
  181.    Select Case hWnd
  182.       Case DBGrid1.hWnd
  183.          If Button = vbMiddleButton Then
  184.             Call MouseWheel1.HorzScroll(hWnd, Delta)
  185.             Cancel = True
  186.          End If
  187.    End Select
  188. End Sub
  189.