|
-
Nov 29th, 2000, 12:01 PM
#1
Thread Starter
New Member
Hi all,
Anyone know how to create click spots on background image (like mapping in HTML) please help. I am stuck on my project.
Thanks in advance.
-
Nov 29th, 2000, 12:05 PM
#2
Frenzied Member
use transparent labels
or use image boxes that contain nothing
-
Nov 29th, 2000, 12:10 PM
#3
transcendental analytic
You want to have rectangular areas that can be clicked on?
Well here's a good sample for you:
Code:
Private Declare Function PtInRect Lib "user32" (lpRect As RECT, pt As POINTAPI) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINTAPI
X As Long
Y As Long
End Type
Private clickspots() As RECT
Private Sub Form_Load()
ReDim clickspots(1)
With clickspots(0)
.Left = 50
.Right = 100
.Top = 50
.Bottom = 100
End With
With clickspots(1)
.Left = 250
.Right = 200
.Top = 50
.Bottom = 100
End With
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim pt As POINTAPI, n&
pt.X = X
pt.Y = Y
For n = 0 To UBound(clickspots)
If PtInRect(clickspots(n), pt) Then
Debug.Print "clicked at area " & n
End If
Next n
End Sub
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 29th, 2000, 12:29 PM
#4
Thread Starter
New Member
Thanks for your help!
Kedaman, where would I place the top part which is the Private funtions?!! Can you show me because it show me the error when I move it to module.
Thanks for your help again.
-
Nov 29th, 2000, 12:45 PM
#5
Hyperactive Member
don't make this so difficult
Don't make this more difficult than it should be.
If you want "click spots" (commonly known as hotspots)
then just create (as someone previously mentioned) a label
that is either transparent or a text frame with nothing in it. This should require no code whatsoever.
I do this in my applications when i'm planting my easter
eggs :P
-
Nov 29th, 2000, 12:45 PM
#6
Fanatic Member
Just place everything that Kedaman posted in your form code. If you want to put the declarations in a module, make them Public.
However, I tried the code and it bombs out VB with an application error.
This line:
If PtInRect(clickspots(n), pt) Then
generates an Application Error that memory cannot be read.
Any suggestions ?
Thanks.
-
Nov 29th, 2000, 01:34 PM
#7
Thread Starter
New Member
I'm a slow learner here, please be patient with me
I create a label but it's overlapped my background image?
I would like to know do i miss to do something?!!
-
Nov 29th, 2000, 01:42 PM
#8
-
Nov 29th, 2000, 01:43 PM
#9
transcendental analytic
hmm ptinrect really crashed, i just picked up that api because it was missing, now i found there was another module with the same function, well was years ago so how could i know
Code:
Private Function ptinrect(rect As rect, pt As POINTAPI) As Boolean
ptinrect = pt.X > rect.Left And pt.X < rect.Right And pt.Y > rect.Top And pt.Y < rect.Bottom
End Function
replace the api with this instead
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 29th, 2000, 02:07 PM
#10
Thread Starter
New Member
Thank you so much!! I got it but I use the imagebox(none) instead of label
Noble, I have to do one more step. Can I swap the image whenever I point the mouse to that location? (only change the image of that location)
I create another same background image but in diff color, I want it cut the same section of the second image and replace to the first background when i move the mouse to the location? any ideas how to do it?!!
-
Nov 29th, 2000, 02:42 PM
#11
Hyperactive Member
hmmm
that sounds tricky
first of all, do you want it to change when you move the
mouse over it or when you actually click on it?
if you want it to change when you click on it, you can
have two pictures boxes, each one displays a different
picture
when you click on one, it sets it's visible property to
false and the visible property of the other image to true
and vice versa for the other picture.
If you want it to change when you simply move the mouse
over it, you're gonna have to experiment with the API
as i'm not sure the best way to do that.
I know there is an API that
tells you the mouse's position on the screen but i don't
know if that's the best way to go about it.
I hope this helps.
Bababooey
Tatatoothy
Mamamonkey
-
Nov 29th, 2000, 02:58 PM
#12
Thread Starter
New Member
Thanks Nobel
Someone told me to use buffer to hold the images and select cases. It is too complicated for me.
-
Nov 30th, 2000, 07:09 AM
#13
Addicted Member
in th top piece of code you don't need to redefine RECT, there is already a rect type:
Type Rect
x1 as long
x2 as long
y1 as long
y2 as long
end type
That type already exists, as for getting mouse position, theres always the VB event Mouse_Event which passes the mouse co-ords as it moves over the object which you can code in, its not perfect thou if you move the mouse over it quickly.
-
Nov 30th, 2000, 08:41 PM
#14
transcendental analytic
Where do you find that RECT Nirces? It's at least not in the typelib that comes with my version of vb.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|