home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / likene1a / myprog6.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-09-24  |  6.6 KB  |  226 lines

  1. VERSION 5.00
  2. Begin VB.Form Form4 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Mouse stuff"
  5.    ClientHeight    =   1440
  6.    ClientLeft      =   4515
  7.    ClientTop       =   4020
  8.    ClientWidth     =   3120
  9.    ControlBox      =   0   'False
  10.    BeginProperty Font 
  11.       Name            =   "MS Sans Serif"
  12.       Size            =   8.25
  13.       Charset         =   0
  14.       Weight          =   700
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    LinkTopic       =   "Form4"
  20.    MaxButton       =   0   'False
  21.    MinButton       =   0   'False
  22.    ScaleHeight     =   1440
  23.    ScaleWidth      =   3120
  24.    ShowInTaskbar   =   0   'False
  25.    Begin VB.CommandButton Command14 
  26.       Caption         =   "Set mouse pos"
  27.       Height          =   375
  28.       Left            =   1560
  29.       TabIndex        =   7
  30.       Top             =   720
  31.       Width           =   1575
  32.    End
  33.    Begin VB.CommandButton Command25 
  34.       Appearance      =   0  'Flat
  35.       BackColor       =   &H00C0C0C0&
  36.       Caption         =   "Exit"
  37.       Height          =   375
  38.       Left            =   1560
  39.       TabIndex        =   6
  40.       Top             =   360
  41.       Width           =   1575
  42.    End
  43.    Begin VB.CommandButton Command23 
  44.       BackColor       =   &H00C0C0C0&
  45.       Caption         =   "mouse disapear"
  46.       Height          =   375
  47.       Left            =   0
  48.       TabIndex        =   5
  49.       Top             =   720
  50.       Width           =   1575
  51.    End
  52.    Begin VB.CommandButton Command6 
  53.       BackColor       =   &H00C0C0C0&
  54.       Caption         =   "Swap mouse"
  55.       Height          =   375
  56.       Left            =   1560
  57.       TabIndex        =   4
  58.       Top             =   0
  59.       Width           =   1575
  60.    End
  61.    Begin VB.CommandButton Command26 
  62.       Caption         =   "Get mouse pos"
  63.       Height          =   375
  64.       Left            =   0
  65.       TabIndex        =   3
  66.       Top             =   360
  67.       Width           =   1575
  68.    End
  69.    Begin VB.TextBox text4 
  70.       Height          =   285
  71.       Left            =   2400
  72.       TabIndex        =   2
  73.       Text            =   "0"
  74.       Top             =   1130
  75.       Width           =   615
  76.    End
  77.    Begin VB.TextBox Text5 
  78.       Height          =   285
  79.       Left            =   840
  80.       TabIndex        =   1
  81.       Text            =   "0"
  82.       Top             =   1130
  83.       Width           =   615
  84.    End
  85.    Begin VB.Timer Timer1 
  86.       Interval        =   1
  87.       Left            =   3600
  88.       Top             =   2520
  89.    End
  90.    Begin VB.CommandButton Command1 
  91.       BackColor       =   &H00C0C0C0&
  92.       Caption         =   "Control mouse"
  93.       Height          =   375
  94.       Left            =   0
  95.       TabIndex        =   0
  96.       Top             =   0
  97.       Width           =   1575
  98.    End
  99.    Begin VB.Label Label2 
  100.       Caption         =   "Y Axis"
  101.       Height          =   255
  102.       Left            =   1680
  103.       TabIndex        =   9
  104.       Top             =   1140
  105.       Width           =   855
  106.    End
  107.    Begin VB.Label Label1 
  108.       Caption         =   "X Axis"
  109.       Height          =   375
  110.       Left            =   0
  111.       TabIndex        =   8
  112.       Top             =   1140
  113.       Width           =   975
  114.    End
  115. Attribute VB_Name = "Form4"
  116. Attribute VB_GlobalNameSpace = False
  117. Attribute VB_Creatable = False
  118. Attribute VB_PredeclaredId = True
  119. Attribute VB_Exposed = False
  120. Dim mmflag As Boolean
  121. Dim sax As Integer
  122. Dim Say As Integer
  123. Private Declare Function mciSendString Lib "winmm.dll" Alias _
  124. "mciSendStringA" (ByVal lpstrCommand As String, ByVal _
  125. lpstrReturnString As String, ByVal uReturnLength As Long, _
  126. ByVal hwndCallback As Long) As Long
  127. Private Type RECT
  128.     Left As Long
  129.     Top As Long
  130.     Right As Long
  131.     Bottom As Long
  132. End Type
  133. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
  134.    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  135.  Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, _
  136.    ByVal nCmdShow As Long) As Long
  137.  Private Const SW_HIDE = 0
  138.  Private Const SW_SHOWNORMAL = 1
  139. Private Sub Command1_Click()
  140. If Command1.Caption = "Control mouse" Then
  141. Command1.Caption = "stop control"
  142. Command1.Caption = "Control mouse"
  143. End If
  144. If Command1.Caption = "stop control" Then
  145. Timer1.Enabled = True
  146. End If
  147. If Command1.Caption = "Control mouse" Then
  148. Timer1.Enabled = False
  149. End If
  150. End Sub
  151. Private Sub Command14_Click()
  152. g = SetCursorPos(Text5.Text, text4.Text)
  153. End Sub
  154. Private Sub Command23_Click()
  155. If Command23.Caption = "mouse disapear" Then
  156. Command23.Caption = "Mouse reapear"
  157. Command23.Caption = "mouse disapear"
  158. End If
  159. If Command23.Caption = "Mouse reapear" Then
  160. ShowCursor (bShow = True)
  161. End If
  162. If Command23.Caption = "mouse disapear" Then
  163. ShowCursor (bShow = False)
  164. End If
  165. End Sub
  166. Private Sub Command25_Click()
  167.     Call ImplodeForm(Me, 2, 500, 1)
  168.     Unload Form4
  169.     Form12.Show
  170. End Sub
  171. Private Sub Command26_Click()
  172. Ret = GetCursorPos(Pos)
  173. VARIABLE = "(" + CStr(Pos.X) + ", " + CStr(Pos.Y) + ")"
  174. Text5.Text = Pos.X
  175. text4.Text = Pos.Y
  176. End Sub
  177. Private Sub Command6_Click()
  178. If Command6.Caption = "Swap mouse" Then
  179. Command6.Caption = "restore mouse"
  180. Command6.Caption = "Swap mouse"
  181. End If
  182. If Command6.Caption = "restore mouse" Then
  183. SwapMouseButton (1)
  184. End If
  185. If Command6.Caption = "Swap mouse" Then
  186. SwapMouseButton (0)
  187. End If
  188. End Sub
  189. Private Sub Form_Load()
  190. Call ExplodeForm(Me, 500)
  191. Timer1.Enabled = False
  192. End Sub
  193. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  194. Call ImplodeForm(Me, 2, 500, 1)
  195. End Sub
  196. Private Sub Timer1_Timer()
  197. Dim mousexy As POINTAPI
  198. q = GetCursorPos(mousexy)
  199. Text5.Text = mousexy.X
  200. text4.Text = mousexy.Y
  201. End Sub
  202. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  203.    Dim fml As Long
  204.    Dim fmt As Long
  205.    Dim a As Integer
  206.    If mmflag = True Then
  207.       fml = Me.Left: fmt = Me.Top
  208.       If X > sax Then Me.Left = fml + (X - sax)
  209.         If X < sax Then Me.Left = fml - (sax - X)
  210.       If Y > Say Then Me.Top = fmt + (Y - Say)
  211.       If Y < Say Then Me.Top = fmt - (Say - Y)
  212.    End If
  213.    End Sub
  214. Private Sub form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  215. If mmflag = False Then
  216.       sax = X
  217.       Say = Y
  218.       mmflag = True
  219.    End If
  220.    Me.MousePointer = vbSizePointer
  221.    End Sub
  222. Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  223.     mmflag = False
  224.    Me.MousePointer = vbDefault
  225. End Sub
  226.