?
Solved

Prevent cursor from entering area

Posted on 2003-03-12
6
Medium Priority
?
203 Views
Last Modified: 2013-12-25
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.
0
Comment
Question by:nimble
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Expert Comment

by:AnitraZ
ID: 8123170
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
 

Author Comment

by:nimble
ID: 8129030
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
 

Expert Comment

by:AnitraZ
ID: 8129333
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:nimble
ID: 8649194
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
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9053233
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
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 9143651
Question is PAQ'd and points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question