RobEmDee Posted August 28, 2003 Posted August 28, 2003 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? Quote
*Experts* Bucky Posted August 28, 2003 *Experts* Posted August 28, 2003 Well if the "hotspots" you're looking for are controls, then you can use the control's 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 form's MouseMove event, you could compare the mouse's position to a collection of Rectangles (created on the form's load) and see if the mouse is inside the Rectangle by using its Contains() method. Just some ideas. Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Runtime_error Posted August 29, 2003 Posted August 29, 2003 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. Quote
davidrobin Posted August 30, 2003 Posted August 30, 2003 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 shouldn't 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? Quote
Runtime_error Posted September 2, 2003 Posted September 2, 2003 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.