I "modified" the API call slightly, and it seems to work. Basically, I am trying to use this API with a map (latitude/longitude). I got tired of getting confused about the top/bottom, min/max weirdness, so I created an alias for the API call and a 'different' rect structure to suit my needs a little better. Basically, I'm just renaming the API call and the 4 members of the Rect structure.
This seems to work properly, but it has lead to another problem, specifically with the API call, and I was wondering if someone knew how to fix or accommodate this problem.
Not that it's important,but... I am trying to use this API call to determine if a road (line) is within the bounds of my map. The problem is, if the road is completely vertical or horizontal, the API call returns 0, and I would prefer for it to return 1 (true).
Here's some sample code to illustrate the problem.
The API call is faster than vb code for determining if something is within the bounds, so I prefer to use it. I'm wondering if there is another API call that would suit my needs any better. Most of the lines I am testing are not vertical or horizontal, but it can happen so I need to accommodate it.
-George
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
This seems to work properly, but it has lead to another problem, specifically with the API call, and I was wondering if someone knew how to fix or accommodate this problem.
Not that it's important,but... I am trying to use this API call to determine if a road (line) is within the bounds of my map. The problem is, if the road is completely vertical or horizontal, the API call returns 0, and I would prefer for it to return 1 (true).
Here's some sample code to illustrate the problem.
Code:
Option Explicit
Private Type MapBound
MinLongitude As Long
MinLatitude As Long
MaxLongitude As Long
MaxLatitude As Long
End Type
Private Declare Function MapIntersect Lib "user32.dll" Alias "IntersectRect" (lpDestRect As MapBound, lpSrc1Rect As MapBound, lpSrc2Rect As MapBound) As Long
Private Sub Command1_Click()
Dim Intersect As MapBound
Dim Rect1 As MapBound
Dim Rect2 As MapBound
Rect1.MinLongitude = 7500000
Rect1.MaxLongitude = 7600000
Rect1.MinLatitude = 4000000
Rect1.MaxLatitude = 4100000
Rect2.MinLongitude = 7550000
Rect2.MaxLongitude = 7550001
Rect2.MinLatitude = 4050000
Rect2.MaxLatitude = 4050001
[green]' The following returns 1[/green]
Debug.Print MapIntersect(Intersect, Rect2, Rect1)
[green]-- make longitude values the same[/green]
Rect2.MinLongitude = 7550000
Rect2.MaxLongitude = 7550000
Rect2.MinLatitude = 4050000
Rect2.MaxLatitude = 4050001
[green]' The following returns [!]0[/!][/green]
Debug.Print MapIntersect(Intersect, Rect2, Rect1)
[green]-- make latitude values the same[/green]
Rect2.MinLongitude = 7550000
Rect2.MaxLongitude = 7550001
Rect2.MinLatitude = 4050000
Rect2.MaxLatitude = 4050000
[green]' The following returns [!]0[/!][/green]
Debug.Print MapIntersect(Intersect, Rect2, Rect1)
End Sub
The API call is faster than vb code for determining if something is within the bounds, so I prefer to use it. I'm wondering if there is another API call that would suit my needs any better. Most of the lines I am testing are not vertical or horizontal, but it can happen so I need to accommodate it.
-George
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom