I did a routine with UDTs for a button demo with hardware acceleration. Taking the above and converting it to UDT's is similar. In this demo you can drag the suare...
Code: (Select All)
Type MyMouse
x As Integer
y As Integer
lb As Integer
rb As Integer
mb As Integer
mw As Integer
clkcnt As Integer
prevx As Integer
prevy As Integer
drag As Integer
End Type
Dim m As MyMouse
Locate 2, 39: Print Chr$(219);
Do
mouse m
Locate 1, 1: Print "Left Click Count: "; m.clkcnt;: If m.clkcnt = 2 Then Sound 1000, .1
Locate 2, 1: Print "Left Button Status: "; m.lb
Locate 3, 1: Print "Middle Button Status:"; m.mb
Locate 4, 1: Print "Right Button Status: "; m.rb
Locate 5, 1: Print "Mouse Wheel Status: "; m.mw: If m.mw Then _Delay .1 ' Delay allows it to show.
Locate 7, 1: Print "Row and Column: "; m.y; " "; m.x; " ";
If m.y Then
If Screen(m.y, m.x, 0) = 219 Or m.drag Then
If m.lb = -1 Then
m.drag = -1
Else
If m.drag Then
If m.y <> m.prevy Or m.x <> m.prevx Then
Locate m.prevy, m.prevx: Print Chr$(32);
Locate m.y, m.x: Print Chr$(219);
End If
End If
End If
End If
End If
Loop
Sub mouse (m As MyMouse)
Static z1
m.prevx = m.x: m.prevy = m.y
If m.mw Then m.mw = 0
While _MouseInput
m.mw = m.mw + _MouseWheel: If m.mw Then m.mw = m.mw \ Abs(m.mw) ' Limit to 1 or -1 for up or down.
Wend
m.x = _MouseX
m.y = _MouseY
If z1 Then If Abs(Timer - z1) > .25 Then z1 = 0: m.clkcnt = 0
Select Case m.lb
Case 2: m.lb = 0 ' Click cycle completed.
Case 1: If _MouseButton(1) = 0 Then m.lb = 2: m.drag = 0 ' Button released.
Case -1: m.lb = 1 ' Button held down.
Case 0: m.lb = _MouseButton(1)
End Select
Select Case m.mb
Case 2: m.mb = 0 ' Click cycle completed.
Case 1: If _MouseButton(3) = 0 Then m.mb = 2 ' Button released.
Case -1: m.mb = 1 ' Button held down.
Case 0: m.mb = _MouseButton(3)
End Select
Select Case m.rb
Case 2: m.rb = 0 ' Click cycle completed.
Case 1: If _MouseButton(2) = 0 Then m.rb = 2 ' Button released.
Case -1: m.rb = 1 ' Button held down.
Case 0: m.rb = _MouseButton(2)
End Select
If m.lb = -1 Then z1 = Timer: m.clkcnt = m.clkcnt + 1
End Sub
Shoot first and shoot people who ask questions, later.

