View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Getting screen coordinates from Range

Hi Edwin,

I found some nice code by keepITcool that handles most of this:
But it still doesn't handle Panes.


I remember that and very nice too. From memory to cater for Panes need to
get the distances from the top & left of the window (incl window border &
header dimensions) to the top-left cell in the active pane. Then add to the
coordinates returned by KeepITcool's routine. Existing code can be easily
adapted to do most of that except getting the window border dimensions.

1) PointsToScreenPixelsX doesn't show up in my VS generated C++
wrappers.


This is a VBA function, not an API, that works with a Window object.

2) What I *really* want is to be able to select/get the location of
some text within a cell, not the cell itself. Is this possible?


Difficult to do this accurately particularly with a proportional font.
Although relatively rare individual characters could be individually font
formatted (size/bold etc). Doable and I've done it but a lot of work that
involves placing text into a column elsewhere, autosizing and returning the
new dimension.

For your baloon could use one of the autoshapes and position directly over
the cell.

Regards,
Peter T

wrote in message
ups.com...
Hi,

I'm trying to get the screen location of a Range object. Currently
I'm doing (C++):

CRange range = application.get_ActiveCell();
int rangeLeft = int(range.get_Left().dblVal / 0.75 ) + 25;
int rangeTop = int(range.get_Top().dblVal / 0.75) + 16;
pWnd-ClientToScreen(&ptForBalloon);

But this obviously has some problems (doesn't handle zooming,
multiple panes, etc).

I found some nice code by keepITcool that handles most of this:

http://groups.google.com.au/group/mi...amming/browse_
frm/thread/4989aac2dde2e778/

But it still doesn't handle Panes.

Anyone know a full solution?

Some other questions:
1) PointsToScreenPixelsX doesn't show up in my VS generated C++
wrappers. Any idea how to deal with this?
2) What I *really* want is to be able to select/get the location of
some text within a cell, not the cell itself. Is this possible?

[The reason I want to do this is to support Excel in my HandyFind
freeware that lets you Find as You Type and displays a balloon to guide
your eye to the found text. I put a preview including Excel support at
http://www.handykeys.com/preview in case you are interested. Any
feedback is much appreciated. Please send it to the email address on
that page.]

Thanks!
-Edwin Evans