Re: How to Obtain Text Node Coordinates
- From: lemax <lemax@xxxxxx>
- Date: 28 May 2007 22:54:48 -0700
I would also appreciate an out-of-the-box way.
If you find something, please contact me.
On May 25, 11:56 pm, "Daniel Mccann" <dmccann_NOS...@lde-
innovations.com> wrote:
Works like a charm, thanks! The only problem is that I'm a little concerned
about performance in the situations where we have a large number of text
nodes that we need to apply this method to. I'd think there must be some
interface or method that we could use to simply return the coordinates (e.g.
like getBoundingClientRect(), which you can't apply to a text node
directly). Am I just missing something obvious?
"lemax" <l...@xxxxxx> wrote in message
news:1179996877.835665.65030@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On May 24, 12:48 am, "Daniel Mccann" <dmccann_NOS...@lde-
innovations.com> wrote:
I need to be able to determine the coordinates of a text node
(IHTMLDOMTextNode), but do not appear to be able to cast it to any
remotely
useful interface whereby I can obtain these coordinates. Does anyone
know
how I can get them?
If there are no interfaces that provide the coordinates, perhaps I can
get
them from the rendering engine.
Any help would be much appreciated!
Thanks,
Dan
It is easy if you you dummy nodes.
Just insert a node like <span> or whatever around it and delete it
after getting the coordinates:
code sample:
CComPtr<IHTMLElement> ptrSpanElement;
CComPtr<IHTMLDOMNode> ptrTextNode; // this is your Textnode you need
the coordinates for
p_ptrNodeToWrap->cloneNode(VARIANT_TRUE,&ptrTextNode);
m_ptrCurrentDocument-
createElement(SysAllocString(L"SPAN"),&ptrSpanElement);if (ptrSpanElement)
{
CComPtr<IHTMLDOMNode> ptrSpanNode;
if (SUCCEEDED(ptrSpanElement.QueryInterface(&ptrSpanNode)))
{
ptrSpanElement->put_id("dummy");
IHTMLDOMNode* ptrTemp = NULL;
ptrSpanNode->appendChild(ptrTextNode,&ptrTemp);
m_ptrCurrentParent-
replaceChild(ptrSpanNode,p_ptrNodeToWrap,&ptrTemp);ptrTemp->Release();
//remove the dummy node
ptrSpanNode->removeNode(VARIANT_FALSE,NULL);
}
}
I hope this helps you out.
Regard,
Thomas
.
- References:
- How to Obtain Text Node Coordinates
- From: Daniel Mccann
- Re: How to Obtain Text Node Coordinates
- From: lemax
- Re: How to Obtain Text Node Coordinates
- From: Daniel Mccann
- How to Obtain Text Node Coordinates
- Prev by Date: Re: HOWTO Embedding IWebBrowser2 in ActiveX control
- Next by Date: APP and history navigation (GoBack,GoForward)
- Previous by thread: Re: How to Obtain Text Node Coordinates
- Next by thread: Auto-detect RSS/Atom feeds on the browsed webpages
- Index(es):