PickObject and Zooming

Hello i have a question. Whats the best way to get the right
coordinates to pick an object in a GoView when it is zoomed or
not…here is the code that used to work without zooming…(in my
GoToolLinkingNew class)


Point p = this.View.PointToScreen(new Point((int)LastInput.DocPoint.X, (int)LastInput.DocPoint.Y));

Then i call a pickobject on this point…I need this because i create links between windows (it works great without zooming)

Normally you should just call GoView.PickObject( …, LastInput.DocPoint, …)
Needing to deal with screen coordinates is uncommon. Is this because you have a screen coordinate point in another window, and that’s what you want to translate to a document point? You should convert from screen coordinates into view coordinates, and then from view coordinates into document coordinates. Here’s code from DoExternalDrop in ProtoApp.GraphView:
protected override IGoCollection DoExternalDrop(DragEventArgs evt) {
. . .
Point screenPnt = new Point(evt.X, evt.Y);
Point viewPnt = PointToClient(screenPnt);
PointF docPnt = ConvertViewToDoc(viewPnt);
. . .
}

Ok problem fixed…

I needed to go from one DocPoint to another doc point in another window… so for the people interested heres how it goes…

// In mouse up of my tool, convert the DocPoint to screen coordinates…
Point
p = this.View.PointToScreen(new
Point((int)(LastInput.DocPoint.X *
View.DocScale),
(int )(LastInput.DocPoint.Y * View.DocScale)));

//Then to find the point in another windows document
//Get Window coordinates…
Point pc = goView1.PointToClient§;
//Get Document coordinates
PointF ps = new PointF(
pc.X * (1.0f/goView1.DocScale),
pc.Y * (1.0f/goView1.DocScale));

//Pick object…
goView1.PickObject(true, false, ps, true);

That first statement is wrong–it doesn’t take into account several other properties of the view. Use LastInput.ViewPoint instead.
The initialization of “ps” is wrong too–it’s also ignoring a bunch of stuff. Use GoView.ConvertViewToDoc instead, as my previous reply did.

what exactly is it ignoring?? What properties can have an effect on my code?

Using LastInput.ViewPoint doesnt work…Thats why im using the first statement…

Does it work if that view is scrolled?

hmm doesnt work when the source view is scrolled…but
LastInput.ViewPoint doesnt work at all even when not scrolled…so do
you have another solution…Now my solution works on the following
cases:

PickObject is done on an object that is scrolled (not in view)
PickObject is done on a zoomed view

The only case it doesnt work is when trying to create a link from a scrolled window to another window…

Is this your code?
Point pscreen = goView2.PointToScreen(goView2.LastInput.ViewPoint);
Point p1view = goView1.PointToClient(pscreen);
PointF p1doc = goView1.ConvertViewToDoc(p1view);
… goView1.PickObject(true, false, p1doc, true);
Have you checked the values along the way to make sure they were reasonable?
Presumably this code is being executed when the mouse has been “grabbed”, so that you can really get events even though the mouse is over a different control/window.

Ok… The code you juste gave me works great…sorry must of done some kind of mistake… Thanks!!!

Works great for me too!