Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MouseOver Events

Status
Not open for further replies.

godspeed06

Vendor
Apr 7, 2006
34
US
Consider that you have a map ud the US, and you want to hotspots if you will for each state on the map. Each hotspot will have a cooresponding 'lablel' informing the person where they can obtain support for their state. How can this be done via an image withing .NET?

I know part of it is now the map coordiantes, but I forget how else you can tell MouseOn/Over/Down events which state has been selected.

Thanks!
 
Luckily there is a great thread on just this: thread796-1061219

That is for a clickable map, but it would be easy enough to modify for a mouse over, just catch the mouse enter/hover events and check the click map image color for the cursor location.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
ThatRickGuy! This is exactly what I am looking for, however, I am not clear on how to get the coordinates to work with the Mouse events. I have a jpg image of my map but don't know how to paste it.

Thanks
 
The mouse hover event has a parameter called 'e' which is a mouse over event arguement (or something like that). It should have a .x and .y property. Those will give you the coordinates in side the object (I think, it's been a while).

First you'll want to take a copy of your image and open it in Photoshop (or other good graphics editing system). You'll want to recolor each distinct area a different solid color. Then you'll want to save this image as your mouse map.

Then add your original image in a picture box on the form. Then catch the mouse hover event for the picture box. In the mouse hover event open the mouse map as a bitmap and use the getpixel method to return the color of the coordinate (e.x, e.y). Then use that color value to select a row from a data table that contains the information about your map.

Download the sample code in that thread and play with it abit. Once you have a good understanding of what it is doing, recreating it for another map shouldn't be too hard.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Rick,
I guess I am really unclear to what a mouse map is. I am familiar however, with add the original image to a form. So, once I save the original image via photoshop, how is this saved within vb.net as a mouse map?

Thanks!
 
If you look in that thread you should see two images. One is of a bright and colorful map of the US, the other is the same map, but all the states are black or dark blue. The black and dark blue map is the click map (or mouse map) each state is a slightly different color that uniquely identifies each state.

So when the user clicks on the colorful map you take those coordinates and look at that point on the click map. The color of the pixel at that point will identify what state they clicked on.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top