Prevent cursor from entering area

Hello,

Just wondering if there is a way to prevent the cursor from entering a certain area on the form.

The reason is I cannot allow a user to right-click on a flash control, and I cannot suppress the right-click.

I am not looking for a ClipCursorRect solution - rather, an inverse ClipCursorRect, allowing a user access to everything but a certain rectangle on a form.  Thanks.
nimbleAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
YensidModConnect With a Mentor Commented:
Question is PAQ'd and points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0
 
AnitraZCommented:
Well, I suggest to control it by yourself: I don't know if the Flash control has a MouseMove event, but all you have to do is to change mouse oordinates when it is over your control. Try this:

Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Long, ByVal y As Long) As Long

Now, when the mouse is over the control, you just call SetCursorPos(), giving as parameters the edge of the control. This code (or something like that) should be placed in the MouseMove event. X and Y are the arguments for MouseMove.

Dim myX as Long, myY as Long
Dim HalfX as Long, HalfY as Long

HalfY=Height/2/15
HalfX=Width/2/15

If (X < HalfX) Then
MyX=Left
Else
MyX=Left+Width 'Right
End If

If (Y < HalfY) Then
MyY=Top
Else
MyY=Top+Height 'Bottom
End If

Call SetCorsorPos(MyX, MyY)

Ok, this should give a good effect when repositioning the mouse. If the cursor comes from top, it will be blocked at top. This is valid only if the control is big enough and the cursor's speed isn't too fast...

AnitraZ
0
 
nimbleAuthor Commented:
Thank you, yes, that is a good idea and I have tried that in a previous attempt at a solution.

There are some problems though.  First, the flash control does not have a MouseMove event.  So, I placed it on a panel, and used the panel's MouseMove event.  So then, second, I would like to prevent the cursor from entering the conrol in all cases.  Unfortunately, this solution does not do that (like you mention, if the cursor's speed is too fast you can get into the control...... I would like to stop that from ever occurring).

Any other ideas?  Thanks.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
AnitraZCommented:
You misunderstood what I said... If the picture is little and the cursor is fast, the code posted above may fail when trying to understand where the mouse comes from. So, if the mouse comes from top at a medium speed, it could enter the control rect, but since it's in the upper half-control, the program supposes that the cursor comes from top, so sets its Y to the top coordinate of the control.
Besides, if the control is small, the mouse could "jump" to the lower part of it, and the program would "think" that the cursor comes from bottom. But this is not a problem, the cursor will be placed on the lower edge, instead of the upper one.

If you don't have a mousemove event, try using a timer with a GetCursorPos() function. Yeah, this sucks, but...

Anyway there should be a way that allows you to create the mousemove event. The code should be similiar to an MFC application, developed using C++, so try asking a C programmer about getting the mosemove message from Windows. API should handle this...

AnitraZ
0
 
nimbleAuthor Commented:
Thanks very much for the proposed solutions.
Unfortunately (or fortunately, I suppose) I could not find an adequate solution to this problem, so I simply disabled the entire form.  I moved on, but the comments provided were at least an attempt - not a solution, but I would like to provide remuneration for effort.

I'm new here - how do I do this without accepting those comments as an answer?  Or does this even matter.

Thanks!
0
 
GPrentice00Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->PAQ - with points refunded

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0
All Courses

From novice to tech pro — start learning today.