home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / ch_code / ch12 / mousepos / mousepos.frm (.txt) next >
Encoding:
Visual Basic Form  |  1997-02-20  |  1.6 KB  |  54 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Mouse Position"
  4.    ClientHeight    =   1575
  5.    ClientLeft      =   60
  6.    ClientTop       =   330
  7.    ClientWidth     =   3630
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   1575
  10.    ScaleWidth      =   3630
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.Label LabelY 
  13.       Caption         =   "Label"
  14.       Height          =   375
  15.       Left            =   2040
  16.       TabIndex        =   2
  17.       Top             =   840
  18.       Width           =   1215
  19.    End
  20.    Begin VB.Label Label2 
  21.       Caption         =   "Mouse Position"
  22.       Height          =   255
  23.       Left            =   240
  24.       TabIndex        =   1
  25.       Top             =   240
  26.       Width           =   2055
  27.    End
  28.    Begin VB.Label LabelX 
  29.       Caption         =   "Label"
  30.       Height          =   375
  31.       Left            =   240
  32.       TabIndex        =   0
  33.       Top             =   840
  34.       Width           =   1215
  35.    End
  36. Attribute VB_Name = "Form1"
  37. Attribute VB_GlobalNameSpace = False
  38. Attribute VB_Creatable = False
  39. Attribute VB_PredeclaredId = True
  40. Attribute VB_Exposed = False
  41. Option Explicit
  42. Private Type POINTAPI
  43.     X   As Long
  44.     Y   As Long
  45. End Type
  46. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
  47. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  48.     Dim MouseLoc As POINTAPI
  49.     Dim retValue As Boolean
  50.     retValue = GetCursorPos(MouseLoc)
  51.     LabelX.Caption = "X Pos = " & MouseLoc.X
  52.     LabelY.Caption = "Y Pos = " & MouseLoc.Y
  53. End Sub
  54.