vbAccelerator - Contents of code file: frmMouseTrack.frm

VERSION 5.00
Begin VB.Form frmMouseTrack 
   Caption         =   "Mouse Leave Demonstration"
   ClientHeight    =   2925
   ClientLeft      =   4200
   ClientTop       =   2145
   ClientWidth     =   4035
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "frmMouseTrack.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   2925
   ScaleWidth      =   4035
   Begin VB.Frame fraType 
      Caption         =   "&Tracking Method:"
      Height          =   1095
      Left            =   60
      TabIndex        =   6
      Top             =   1740
      Width           =   3915
      Begin VB.OptionButton optMethod 
         Appearance      =   0  'Flat
         Caption         =   "SetCapture/ReleaseCapture Workaround"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   2
         Left            =   60
         TabIndex        =   9
         Top             =   720
         Width           =   3735
      End
      Begin VB.OptionButton optMethod 
         Appearance      =   0  'Flat
         Caption         =   "COMCTL32 emulation TrackMouseSelect"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   1
         Left            =   60
         TabIndex        =   8
         Top             =   480
         Width           =   3735
      End
      Begin VB.OptionButton optMethod 
         Appearance      =   0  'Flat
         Caption         =   "USER32 TrackMouseSelect"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   0
         Left            =   60
         TabIndex        =   7
         Top             =   240
         Width           =   3675
      End
   End
   Begin VB.PictureBox picTrack2 
      Height          =   1155
      Left            =   1380
      ScaleHeight     =   1095
      ScaleWidth      =   1155
      TabIndex        =   4
      Top             =   60
      Width           =   1215
   End
   Begin VB.PictureBox picVB 
      Height          =   1155
      Left            =   2700
      ScaleHeight     =   1095
      ScaleWidth      =   1215
      TabIndex        =   2
      Top             =   60
      Width           =   1275
   End
   Begin VB.PictureBox picTrack 
      Height          =   1155
      Left            =   60
      ScaleHeight     =   1095
      ScaleWidth      =   1155
      TabIndex        =   0
      Top             =   60
      Width           =   1215
   End
   Begin VB.Image imgPic2 
      Height          =   480
      Left            =   3960
      Picture         =   "frmMouseTrack.frx":1272
      Top             =   4260
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Label lblMouse2 
      Caption         =   "Not over"
      Height          =   735
      Left            =   1380
      TabIndex        =   5
      Top             =   1260
      Width           =   1275
   End
   Begin VB.Image imgPic 
      Height          =   480
      Left            =   3300
      Picture         =   "frmMouseTrack.frx":1B3C
      Top             =   4260
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Label lblVB 
      Caption         =   "-"
      Height          =   435
      Left            =   2700
      TabIndex        =   3
      Top             =   1320
      Width           =   1275
   End
   Begin VB.Label lblMouse 
      Caption         =   "Not over"
      Height          =   735
      Left            =   60
      TabIndex        =   1
      Top             =   1260
      Width           =   1275
   End
End
Attribute VB_Name = "frmMouseTrack"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private WithEvents m_cPTM As cMouseTrack
Attribute m_cPTM.VB_VarHelpID = -1
Private WithEvents m_cP2TM As cMouseTrack
Attribute m_cP2TM.VB_VarHelpID = -1

Private Sub Form_Load()
   
   Set imgPic.Container = picTrack
   imgPic.Move (picTrack.ScaleWidth - imgPic.Width) \ 2, (picTrack.ScaleHeight
    - imgPic.Height) \ 2
   Set imgPic2.Container = picTrack2
   imgPic2.Move (picTrack.ScaleWidth - imgPic2.Width) \ 2,
    (picTrack.ScaleHeight - imgPic2.Height) \ 2
   Set m_cPTM = New cMouseTrack
   m_cPTM.AttachMouseTracking picTrack
   Set m_cP2TM = New cMouseTrack
   m_cP2TM.AttachMouseTracking picTrack2, m_cPTM.Method
   
   optMethod(m_cPTM.Method).Tag = "CODE"
   optMethod(m_cPTM.Method).Value = True
   
End Sub


Private Sub m_cP2TM_MouseHover(Button As MouseButtonConstants, Shift As
 ShiftConstants, x As Single, y As Single)
   ' Hover event, support for user32 and comctl32 methods:
   lblMouse2.Caption = "Mouse Hover!"
   m_cP2TM.StartMouseTracking
End Sub

Private Sub m_cP2TM_MouseLeave()
   ' End tracking:
   Debug.Print "2:Mouse Left"
   lblMouse2.Caption = "Mouse Has Left Control"
   imgPic2.Visible = False
   picTrack2.BackColor = Me.BackColor
End Sub

Private Sub m_cPTM_MouseHover(Button As MouseButtonConstants, Shift As
 ShiftConstants, x As Single, y As Single)
   ' Hover event, support for user32 and comctl32 methods:
   lblMouse.Caption = "Mouse Hover!"
   m_cPTM.StartMouseTracking
End Sub

Private Sub m_cPTM_MouseLeave()
   ' End tracking:
   lblMouse.Caption = "Mouse Has Left Control"
   imgPic.Visible = False
   picTrack.BackColor = Me.BackColor
End Sub

Private Sub optMethod_Click(Index As Integer)
   If optMethod(Index).Tag = "" Then
      m_cPTM.AttachMouseTracking picTrack, Index
      m_cP2TM.AttachMouseTracking picTrack2, Index
   Else
      optMethod(Index).Tag = ""
   End If
End Sub

Private Sub picTrack_MouseMove(Button As Integer, Shift As Integer, x As
 Single, y As Single)
   ' Tracking is initialised by entering the control:
   If Not (m_cPTM.Tracking) Then
      picTrack.BackColor = vbHighlight
      lblMouse.Caption = "Mouse over control"
      m_cPTM.StartMouseTracking
      imgPic.Visible = True
   End If
End Sub

Private Sub picTrack2_MouseMove(Button As Integer, Shift As Integer, x As
 Single, y As Single)
   ' Tracking is initialised by entering the control:
   If Not (m_cP2TM.Tracking) Then
      picTrack2.BackColor = vbHighlight
      lblMouse2.Caption = "Mouse over control"
      m_cP2TM.StartMouseTracking
      imgPic2.Visible = True
   End If
End Sub

Private Sub picVB_MouseMove(Button As Integer, Shift As Integer, x As Single, y
 As Single)
   lblVB.Caption = "Mouse at " & x & "," & y
End Sub