Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27469

mouse down question

$
0
0
Hi All,
I have a question and I hope I make sense.
im trying to replicate the iphone single finger panning in vb.net. now I know windows 7 can handle this for me but the touch screen im using is mouse emulation which means windows doesnt like it (more doesnt recognise it as touch monitor).

Now I have played with the below (in VBA as not at my dev computer) and can get the frame to scroll with the mouse BUT i also want it to scroll if you press the button and move your finger.

is there a way to say if mouse moves over this area regardless of whats underneath scroll this control?

code so far for those that wish to see (just frame on a form with buttons in frame)

Code:

Dim asd As Boolean
Dim xs As Integer
Dim dsa As Integer

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Dim pos As POINTAPI ' Declare variable

Private Sub Frame1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 1 Then
asd = True

GetCursorPos pos
xs = pos.X
Else
asd = False
End If
End Sub

Private Sub Frame1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If asd = True Then
GetCursorPos pos
dsa = pos.X
If dsa < xs Then
Frame1.ScrollLeft = Frame1.ScrollLeft + 5
ElseIf dsa > xs Then
Frame1.ScrollLeft = Frame1.ScrollLeft - 5
End If

End If
End Sub

Private Sub Frame1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If asd = True Then
asd = False
End If
End Sub

Private Sub UserForm_Activate()
Dim cnt As Control
 
For Each cnt In Frame1.Controls
    If cnt.Left + cnt.Width > Frame1.ScrollWidth Then
        Frame1.ScrollWidth = cnt.Left + cnt.Width + 10
    End If
   
Next

End Sub

any help would be awesome (i can scroll the above if room is left on the frame but most people are used to being able to scroll over the buttons as well )
if i havent been clear let me know as my head and fingers dont always agree :)

Viewing all articles
Browse latest Browse all 27469

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>