Mouse OutSide A Form

klaus

Expert
Licensed User
Longtime User
This happens only with MouseMove and MouseUp on the desktop.
If you want to avoid getting values from outsides you must check if x and y are insides the form limits.
B4X:
If x >=0 and x<= Form.Width and y>= 0 and y<=Form.Height Then

Be aware that there is also a difference in the behaviour of the MouseMove event between the desktop and the device. On the desktop the MousMove event is fired even without a MouseDown event, on the device the MouseMove event is only fired after a MouseDown event (the contact of the stylus is needed). To avoid this you should add a flag in the MousDown event, test it in the MouseMove event and set it back in the MousUp event:
B4X:
Sub Form_MouseDown(x,y)
  FlagMouse = 1
End Sub
 
Sub Form_MouseMove(x,y)
  If FlagMouse = 1 Then
  End If
End Sub
 
Sub Form_MouseUp(x,y)
  FlagMouse = 0
End Sub

Best regards.
 

eww245

Member
Licensed User

Thanks for the response.

I was actually hoping it was possible on the device.

I was having issues with a PInvoke to GetIdleTime / GetTickTime.
It wasn't working the way I hoped.
And thought if I could detect when there were no clicks outside a form, it would achieve the same.

I have since worked out the correct calculation and works great.

Thanks Anyway
 

Mr_Gee

Active Member
Licensed User
Longtime User
I'm still tring to get this to work on the desktop, but i can only get the mousemove to trigger when it is on the form...
:-/

probably because i'm using sub form1_mousemove(x,y)..
 

Mr_Gee

Active Member
Licensed User
Longtime User
Byak@

Thanks Byak@,

Any chance you also know how to get the pixel color
at a specific position, also outside of the form?

I've been fiddling with the door lib... but it is not my day
 

Byak@

Active Member
Licensed User
emm...i'm not find it in msdn =(
but you can get screenshot with dzHW.dll and get mouse position.and now you can get pixel color.but this method not fast.
 

Mr_Gee

Active Member
Licensed User
Longtime User
that was my next option... hopefully someone else reads this..
or i might make a new post

 

Mr_Gee

Active Member
Licensed User
Longtime User
In case anyone is wondering, the above worked,
e.g. I'm taking a screenshot of 1x1 pixel and checking the RGB color
with Agraham's ImageEX lib...
Put this sub on a timer and presto... a color picker
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…