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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is it possible to create a hot spot on a picture?

Status
Not open for further replies.

jono261970

Programmer
Jun 28, 2002
182
0
0
GB
Hello,

I am using VB 6.0 to create a program for students at school. I have taken a photograph of a motherboard and added letters to various components using paintshop pro.

I have then inserted the picture into a picture box control. I would like the students to then select a component with the mouse. As this is one object and one picture is it possible to create hotspots on the picture. So hotspot1 one could x,y, hotspot 2 could be x1,y1 etc.

I have also thought about placing a lable on certain areas of the picture. This did work, however the background of the label did spoil the picture as you cannot make it transparent. if you make the label invisible then the function doesn't work.

Any ideas would be much appreciated.

cheers

jono

A good fortune may forbode a bad luck, which may in turn disguise a good fortune.
 
The background of the label can be made transparent and it works fine.
Check the BackStyle property of the label control and make it 0.
 
Hello Hypetia,

Thanks very much for your help. I could kick myself for not seeing that in the first place.

cheers,

jono
A good fortune may forbode a bad luck, which may in turn disguise a good fortune.
 
Here is a thought.....

...create a cmd button that does what you want
...place it on top of the picture area you want to be a hotspot and change the buttons transperancy property to yes

ive done this a couple of times and it works wonderfully. i use the hidden buttons as hotspots to launch message boxes or subforms.

hope this helps.

"I have no special talent. I am only passionately curious.”
~Einstein
 
Well, I think command buttons in VB do not expose a transparency property.
 

Using the mouse move events of whatever object you are using to display the graphic could be easier that using another control. You just need to define the area you want in code to create the hot spot...
[tt]
Option Explicit

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

If X > 100 And X < 1100 And Y > 100 And Y < 415 Then
MsgBox &quot;Hot Spot&quot;
End If


End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

'simple hot spot defined as left 100 top 100 width 1000 height 315

If X > 100 And X < 1100 And Y > 100 And Y < 415 Then
Picture1.MousePointer = vbCrosshair
Else
Picture1.MousePointer = vbDefault
End If

End Sub
[/tt]

Good Luck

 
This method works but the code becomes bulky if you want to have too many hotspots on the picture - say 30 hotspots.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top