Hi,
I'm doing a kind of control picker like the one in spy++ but for html
document.
When the control picker is over an IFRAME, the mshtml function
ElementFromPoin t return an IFrame element.
How can I identify this particular frame/iframe in the frame
collection??? I can only select frame in the framecollection by using
the index or the frame name but the frame name is not always defined.
This is the part of code that try call recursivly
ElementFromPoin t...only the last section of the code is releated to my
question
using mshtml;
//..
//--- Get document
IHTMLDocument2 HtmlDoc;
IHTMLDocument3 HtmlDoc; // to get HtmlDoc3.docume ntElement.Scrol lTop,
ScrollLeft
HtmlDoc = GetIHTMLDocumen tFromHandle(fou nd); /found=internet
explorer_server handle
HtmlDoc3 = GetIHTMLDocumen tFromHandle(fou nd);
//--- Get the elementfromPoin t in the main page
IHTMLElement Element;
Point pt;
pt = new Point(Control.M ousePosition.X, Control.MousePo sition.Y);
ScreenToClient( found, ref pt);
Element = HtmlDoc.element FromPoint((int) pt.X, (int)pt.Y);
//--- Determine real element size and position relative to the main
page.
int ElementLeft = Element.offsetL eft;
int ElementTop = Element.offsetT op;
mshtml.IHTMLEle ment TmpElem = Element.offsetP arent;
while (TmpElem != null)
{
ElementLeft = ElementLeft + TmpElem.offsetL eft;
ElementTop = ElementTop + TmpElem.offsetT op;
TmpElem = TmpElem.offsetP arent;
}
//--- Highlight element
HighlightHtmlEl ement(found, ElementLeft - ScrollLeft, ElementTop -
ScrollTop, (int)Element.of fsetWidth, (int)Element.of fsetHeight);
//This is where my nightmare begins
if (Element.TagNam e.ToString().To Lower()=="ifram e")
{
// Need to get an IHtmlDocument2 that point to the correct frame.
FramesCollectio n frm = (mshtml.FramesC ollection)HtmlD oc.frames;
for (int Cnt=0;Cnt<frm.L ength)
{
object FrameRefIndex=C nt; //This is the
mshtml.IHTMLWin dow2 HtmlWin = (mshtml.IHTMLWi ndow2)frm.item( ref
FrameRefIndex);
Trace.write("In ner html of the
iframe="+HtmlWi n.Document.Body .InnerHtml.ToSt ring());
// If (the framed document is the one contained in the iframe
tag returned by ElementFromPoin t)
// doing my stuff to highlight the elements
}
}
MY QUESTION : In the last line of code it look like there is no way to
identify which framed document is associated with my iframe element
returned by ElementFromPoin t.
I'm desesperatively working on this frame issue since many many many
many hours :( Really need help of an mshtml good samaritin expert.
Thanks