?
Solved

Emulating MouseOver event for a UserControl

Posted on 2003-03-06
6
Medium Priority
?
698 Views
Last Modified: 2013-12-25
I’ve created a custom UserControl which in itself contains a number of UserControls as well. Is it possible to emulate something like a MouseOver event?

I would like to know what control I am over (within my UserControl) at any given MouseMove.

So more specifically, when I place my UserControl on a form I would like to be able to detect what control (within the usercontrol) I am over. This can be an event or just a way to compare screen coordinates to child-control coordinates.

Any help would be greatly appreciated.
0
Comment
Question by:djshorty
[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
  • 3
  • 2
6 Comments
 
LVL 14

Accepted Solution

by:
Esopo earned 400 total points
ID: 8085432
This is a bit heavy, but you could:

1.
Put a hook to the MouseMove of the owner (form) or
check the mouse_event API for movement.
**
Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)  
**

2.Compare the cursor's position with the control's position using GetCursorPos API
**
Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
**

3. Trigger the event.

If you are not familiar with this API calls, you are in for some reading.

I hope this helps.

Best regards.
0
 

Assisted Solution

by:cpcode
cpcode earned 400 total points
ID: 8141615
If the internal usercontrols are not too complex, my suggestion is to bite the bullet and add a mousemove event handler for each item inside these usercontrols, as well as the usercontrols themselves. Then you can declare an event inside each of the usercontrols such as
   public event MouseMoveSomewhereInsideMe()

and raise the event whenever anything inside a usercontrol receives a mousemove event.

The main container usercontrol can then catch these events:
   private sub MyControl1_MouseMoveSomewhereInsideMe()
      ' Raised anytime the mouse moves anywhere inside
      ' MyControl1
   end sub

If all you need is to know when the mouse enters & exits a control, you can simplify the above with state flags.
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9053182
This question has been classified as abandoned.  I will make a recommendation to the moderators on its resolution in a week or two.  I would appreciate any comments by the experts that would help me in making a recommendation.

It is assumed that any participant not responding to this request is no longer interested in its final deposition.

If the asker does not know how to close the question, the options are here:
http://www.experts-exchange.com/help/closing.jsp

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

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

 -->Split between Esopo and cpcode

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0
 
LVL 14

Expert Comment

by:Esopo
ID: 9125898
If my comment didn't help I don't want points for it.

I meant it as a suggestion not an answer.

Regards,


Esopo
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9127846
Esopo

In my experience, sometimes the best answers are merely suggestions - something about teaching a man to fish instead of giving him a fish.  Suggestions can serve as a good jumping point for people later searching to have a new guiding direction, especially ones with multiple alternatives that can be individually researched further.

Hopefully the asker will make the determination.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

765 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