PDA

Click to See Complete Forum and Search --> : *resolved* Hot spots on scrollable image


Monkey Man
Dec 13th, 2002, 06:21 AM
Hello peeps,

I'm trying to make a program which will have a picture (usually too tall to fit completely on screen - hence it will have to be scrollable) - and I want to add multiple hot spots around the picture so the user can click on the relevant part.

I can get the image in mulitple formats - i.e .pdf, .gif, .jpg etc. Which would be the best to use & how can it be done...

TIA

Jordan

NoteMe
Dec 13th, 2002, 07:24 PM
First you would have to know how to open up the warious file formats...a good start would probably be to look at this page...

http://www.filespecs.com/index.jsp

...BTW good luck...

Machaira
Dec 13th, 2002, 07:53 PM
If you don't need anything except rectangular hot spots, just keep an array of rects in memory and use the IntersectRect API call. You'll have to calculate the rect on the PictureBox based on the full picture view, not just the portion visible on screen.

Monkey Man
Dec 16th, 2002, 10:26 AM
Can you create the rects inside the picture box or would I have to move the boxes when the user uses the scroll bar. There will be around 30 hot-spots needed (possibly more) when just a portion is shown with about 50 hidden out of screen. I think it would take too much to calculate when a hot-spot has passed the boarder and assign a new rect when a new one enters.

As with the natwest - there must be another way....

TIA

NoteMe
Dec 16th, 2002, 10:32 AM
What Machaira was talking about was not having a physically box...just some X and Y coordinates in memory. So an array of those X,Y coordinates (rects) can hold the hot spots...And you would have to add how much you have scrolled in X and Y direction to the cursor click to see if it hits a hot spot....

Monkey Man
Dec 17th, 2002, 05:50 AM
I've been doing some searching & found that you can put controls into picture boxes (i.e labels) which will keep their dimensions (i.e left, top, width & height) relative to the picture box (so if the control is at the top left of the picture box it's left & top properties will be 0,0. This would be great because it means I can load all of the hot spots up at the start and not have to recalculate when the user scrolls. Just one question:

What control should I use (should I use one with a hWnd handle so I can hot-track - or just lots of captions & use the tag to process info on the label click)

The main thing I'm looking for is speed.

Thanks for your help.

Machaira
Dec 17th, 2002, 08:47 AM
Take a look at the attached and see if it's what you're looking for.

Stick any picture in PictureBox1 and click in the picture. If you click in the region marked by the rect in the code you'll get a message box even if you scroll the picturebox.

This took me about 2 minutes to whip up so don't expect perfection. :)

Monkey Man
Dec 17th, 2002, 09:16 AM
Perfect, just what I needed...

Thanks all..... :)