MP2004 - XYToLocation

AndyWood
05-30-2006, 09:48 AM
I want to know the extent of the displayed map, so I have a MapPoint control on a VB6 form and it's width and height are 900 x 900. I want to get the top left and bottom right coordinates - using of course using Gilles' CalcPos.

So I do :-

Dim X As Double
Dim Y As Double
X = 0
Y = 0
Set objLoc = MP.ActiveMap.XYToLocation(X, Y)

All OK...

X = MP.Width-1
Y = MP.Height-1
Set objLoc = MP.ActiveMap.XYToLocation(X, Y)

And our old friend -2147024809 The parameter is incorrect makes an appearance!

It will only work if you subtract 6 from Height and Width, and if you do a MouseMove and look at the X and Y the range is 0 to 893.

Any ideas why?

Andy.

Wilfried
06-01-2006, 07:18 AM
Hi,

You are right, I checked in my code and this is how I find the center of a map:

int x = (MP.Width - 6) / 2;
int y = (MP.Height - 6) / 2;

I did never search to it. I think it has to do with the 3D stile of the control (all sides 3 pixel).

AndyWood
06-05-2006, 10:13 AM
Thanks for that - I thought it was me!

Andy.

 
Web mp2kmag.com
mapforums.com