1. Try maybe ,

if your zone on your map are in color you could use
point method:

Code:
```Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Picture1.Point(X, Y) = ??? Then
End Sub```

2. 1. You could separate the map into rectangular areas using RECT UDT, and then have a method to check for in which area as clicked.

2. YOu could have use points instead of rect whereas you click within a range from that point, by it's radius.

3. You can use a invisible triggermap that is a bitmap colored with different colors for each zone, so when you click on the map, you check the triggermap for the same coordinates and get the zone.

3. City Map

Hi-
I never used a point before. I am reading about the point coordinates. But is there any easy way to determine the coordinate of the specific point?

SOhel

4. The point - idea, is to create circular areas to click within. You place out the points by creating either a 3d array or a 1d array of UDT's, i'll elaborate the later one:

Code:
```Type PointZone
X As integer
Y As integer
R As integer
End Type```
The coordinate for each point is specified in X and Y, while R specifies the range within you can click the point. YOu could also keep the R constant for each point, and remove it from the UDT.

To create this array, you can choose to create a fixed or dynamic array, you can add points later on with dynamic arrays so i show you how to do:
Code:
```'This declares the array:
Private PointZones() as PointZone
'And it's good to keep track of the amount of items even if you can get it with Ubound:
Private PointZcount as integer
'This resizes the array to contain the amount of points you need:
PointZcount = 10
Private PointZones(PointZcount-1)
'to set the values use the array
PointZones(0).X = 50
PointZones(0).Y = 70
PointZones(0).R = 10```
Now to check if you clicked on a region, and in that case, which one you just check the distance between:
Code:
``` Function ZoneClicked(X As Integer, Y As Integer) As Integer
Dim n As Integer
For n = 0 To PointZcount - 1
If ((PointZones(n).Y - Y) ^ 2 + (PointZones(n).X - X) ^ 2) ^ 0.5 _
< PointZones(n).R Then ZoneClicked = n: Exit Function 'found
Next n
ZoneClicked = -1 'failure
End Function
'you can use this function for instance in the picturebox mousedown event to check which zone was clicked, it should return the index in the array and -1 if out of all zones.```

5. Invisible trigermaps

Originally posted by kedaman

3. You can use a invisible triggermap that is a bitmap colored with different colors for each zone, so when you click on the map, you check the triggermap for the same coordinates and get the zone.
This seems like a perfect idea, except that the point(x,y) value of a picturebox that is invisible or hidden behind another form object always returns -1

I tried making the triggermap visible before taking the point value, then setting it invisible again, but things get out of sync and VB catches the color of the pixel behind it instead.

Any ideas?

Tom

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•