Positioning html tags under frames

P

Philippe Roy

I need to know where some IHTMLElement are positioned in a browser
page. I have successfully positioned them with the algorithm below.
But, I can't get it to work when the IHTMLElement is within a frame!
Would soneone be kind enough to give me a hint on how to do that?

bool CIEHlprObj::GetElementLocation(IHTMLElement *pElement, RECT
*dRect)
{
dRect->top = 0;
dRect->bottom = 0;
dRect->right = 0;
dRect->left = 0;
long dValue = 0;
IHTMLElement *curElement = pElement;
do
{
if (SUCCEEDED(curElement->get_offsetTop(&dValue)))
{
dRect->top += dValue;
}
else
{
return false;
}
if (SUCCEEDED(curElement->get_offsetLeft(&dValue)))
{
dRect->left += dValue;
}
else
{
return false;
}
IHTMLElement *parentElement = NULL;
if (SUCCEEDED(curElement->get_offsetParent(&parentElement)))
{
curElement = parentElement;
}
else
{
return false;
}
}
while (curElement != NULL);
if (SUCCEEDED(pElement->get_offsetWidth(&dValue)))
{
dRect->right = dRect->left + dValue;
}
else
{
return false;
}
if (SUCCEEDED(pElement->get_offsetHeight(&dValue)))
{
dRect->bottom = dRect->top + dValue;
}
else
{
return false;
}
return ((dRect->bottom > dRect->top) && (dRect->right > dRect->left)
&& (dRect->left >= 0) && (dRect->top >= 0));
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,159
Messages
2,570,886
Members
47,419
Latest member
ArturoBres

Latest Threads

Top