On Sat, Jan 12, 2013 at 3:59 PM, Staffan Tylen <staffan.tylen@gmail.com> wrote:
I'm having an issue with the ListView hitTestInfo method and it may boil down to the fact that I'm not clear over what is meant by the 'coordinates area coordinates' as described in the doc.

Hi Staffan,

That should read:

The point, in client coordinates, to test.

With the link on coordinates.  Unfortunately some of the text around my links got mangled when we converted to Publican for the docs.

Following the link to 1.2.17 Screen / Client Coordinates it's impossible to determine if the screen or client coordinates should be given as argument to the hitTestInfo method.

So, if it had read correctly you would have known you needed to use client coordinates.
Also there is no saying on how to establish these coordinates.

In Windows, the coordinate system used, has an origin of (0, 0) that is the upper left corner.  Moving to the left increases the X coordinate, moving down increases the Y coordinate in this system.  

Screen coordinates are relative to the upper left corner of the screen, or monitor.  Client coordinates are relative to the upper left corner of the client area of whatever window you are talking about.

So, in this specific case, you need to use client coordinates of the list-view.  How you establish that is dependent on how you got, or get, your point.

If you were to just make up a point, say point (0, 0) and you are in report view, then I can tell you off the top of my head that you would get back -1, because the point would be in the column header portion of the list-view.

If you let me know where you are getting the point from, I can help with the conversion.

Say you used the Mouse class, getCursorPos().  The doc there reads correctly, so that you know the point returned is in screen coordinates.  Therefore you would need to use screen2client() to convert the point.

Don't use the screenToClient() method, which is an old IBM method and is inaccurate.

Then the next thing to think of is which client is the conversion for.  In your case, it is the list-view, so you need to use the list-view object and invoke the screen2client() method on it.  Similar to this:

list = self~newListView(n)
mouse = .Mouse~new(list)

p = mouse~getCursorPos


At this point the current cursor position, p, in screen coordinates, has been transformed to a point in client coordinates of the list-view.

The key is determining if the point is in screen coordinates or client coordinates and which window is going to be the client.

Another example is suppose you have a point in client coordinates of the dialog itself.  In this case you would need to use client2screen on the dialog object to convert its client coordinates to screen coordinates.  Then you would use screen2client on the list-view object to get the client coordinates relative to the list-view's client area.

Mark Miesfeld