Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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...9aac2dde2e778/ 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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Peter T wrote:
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. How do I get the distance to the pane? I don't see any methods on Pane that would help me do this. The only one that looks like it might help is VisibleRange, but the locations I get back from the returned Range are relative to the pane. Am I missing something? The only other way I can think to get the pane offset is to look for the little splitter subwindows (window class XLCTL). I think this should work -- for the versions of Excel I've looked at least -- but it sure isn't nice. 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. Actually, I figured out how to do this one. I know it isn't a windows API. I'm using the COM interfaces that Excel exposes (since I needed a small program that interacts with various programs on the fly). For what it's worth, this is what I needed, which I found using OleView.Exe: long PointsToScreenPixelsX(long Points) { long result; static BYTE parms[] = VTS_I4; InvokeHelper(0x6f0, DISPATCH_METHOD, VT_I4, (void*)&result, parms, Points); return result; } I updated my preview (http://handykeys.com/preview) now that scrolling and zooming is working. 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. Interesting. Indeed, it sounds like a lot of work though and I'd hate to do anything that ended up modifying the user's spreadsheet if something went wrong. I may have to live with just selecting the Cell, for now. I'm surprised Microsoft can live with this in their user interface! Wouldn't it be better to highlight the location of the found text? Perhaps they didn't want Find Next to ever stay in the same cell, but it doesn't seem like it would be that hard to highlight all the occurrences. -Edwin Evans Creator of HandyFind freeware (http://handykeys.com) -- Find as you Type in Notepad, Internet Explorer, Microsft Word, and more. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
And once again: X and Y Screen Coordinates of a Range | Excel Programming | |||
X and Y Screen Coordinates of a Range !!! | Excel Programming | |||
Cell address nearest to screen coordinates | Excel Programming | |||
determining coordinates for screen placement of user form | Excel Programming | |||
Screen Coordinates of a given cell in XL | Excel Programming |