Image Hotspots

RobEmDee

Well-known member
Joined
Mar 25, 2003
Messages
130
Location
Richmond, VA
I am interested in creating "hotspots" in an image on a Windows Form similar to what is possible in web pages using javascript. I would like to be able to react to a mouseover event. Does anyone have any suggestions for accomplishing this?
 
Well if the "hotspots" youre looking for are controls, then you can
use the controls MouseEnter, MouseMove, and MouseExit events
to handle the spots. Or you could place PictureBoxes or some other
control around the form and use their mouse events as the
hotspot handlers. Or, in the forms MouseMove event, you could
compare the mouses position to a collection of Rectangles
(created on the forms load) and see if the mouse is inside the
Rectangle by using its Contains() method.

Just some ideas.
 
If u want non rectangular hotspots then the best way to do them is to use windows regions. U will need to have the xy coordinates of each of ur points that make up the hotspot. Simply pass this to the windows region constructor and a hotspot will be created at that location.
Then u can use mouse down event to find if the mouse is within a particular hotspot. I did this application in c++ builder but its not hard to imlement it in c#.
just look into windows regions and drawing on the form. Simply draw ur image as the form background then construct hotspots on the form. After that everytime mouse is down, check if that point is within a region.
 
I was actually in the process of designing a project that uses hotspots.

In my case it will be a plan of a building. Each room is a hotspot, this shouldnt be too bad as almost all rooms are boxes.
I was also thinking of using this technique for continents of a world map.

I have only used regions for odd shaped forms in VB6.
Simply pass this to the windows region constructor and a hotspot will be created at that location
Does this mean that regions are different in .NET as in VB6?
 
Requirements
Namespace: System.Drawing

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family, .NET Compact Framework - Windows CE .NET

Regions in .Net are probably more easier than VB6. Simply Add the Drawing Namespace and u can acess the full functionality of Regions class.

As u probably know a Region is an invisible area that you can click in, draw in etc. So for ur world map it would be a good solution.

There are tools avilable on the internet that will let u record the coordinates of each part of ur pic, but u can easily make it in any programming language by simply recording the X,Y coordinate of each mouse click.

Oh yeah EdgeTracer lets u do this.
 
Back
Top