473,545 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mshtml and frames/iframes

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
Sep 15 '08 #1
1 8698
On Sep 15, 1:51*am, michelqa <miche...@yahoo .cawrote:
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.IHTMLWi ndow2 HtmlWin = (mshtml.IHTMLWi ndow2)frm.item( ref
FrameRefIndex);
* * * *Trace.write("I nner 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
The only way I can imagine is to manually scan all document element...
pseudo maybe look like this :

FrameIndex=0
foreach element in the document
{
if (elment TagName="iframe " or "frame")
{
if the element got the same offsetleft an offsettop as the item
returned by elementfrompoin t= break the loop
FrameIndex++
}
FrameIndex will be my frameindex and now i will ***MAY*** be able to
identify the right frame....

but this assume that the frame collection parse all the frame exactly
the same way as my application when parsing each element and counting
my own index

I'm sure it's not the right way to do this :(
Sep 15 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3904
by: maxim vexler | last post by:
I'm reading a lot of talks lately about the term iFrame and with your permission would like to ask a few question about that : - what is iFrame, i mean what is it good for ? - does all the popular browsers support it (mostly mozilla & the much hated IE, google says the do but nothing is better that experienced answer) - iFrames replaces the...
4
2671
by: Arne Hendrickson | last post by:
Can anyone tell me how to edit this script for "traditional frames" to work with iframes? SCRIPT language="JavaScript"> <!----hide function change2() { parent.left_frame.location="page3.htm"; parent.right_frame.location="page4.htm"; }
6
7087
by: adnanx82 | last post by:
Hi, I was wondering if anyone knew how to perform the following 2 tasks in Javascript: 1) distinguish between frames and iframes (during an onload event for example) 2) figure out whether a container page has finished loading completely with all its component frames or iframes (onload event is not useful because we have more than one...
1
1587
by: Owen | last post by:
I believe that different browsers treat frames/iframes differently, and this is one of the reasons to avoid using them in websites/applications. Are there any other reasons to avoid them? In my experience I find them clunky and messy to implement using javascript and prefer to keep the whole web page as a single page.
4
17620
by: David Pendrey | last post by:
Hello all, I am using the WebBrowser control to browse a webpage containing frames and am having difficulties accessing the 'frames' property of a document object. Bellow is my code and the error recieved: webAccess.Navigate(URL); // Wait until document is loaded. This part DOES work IHTMLDocument2 mDoc =...
4
3283
by: Lars-Erik Aabech | last post by:
Hi! I've been walking in extacy since reading the article about test automation with IE in the latest MSDN mag. (http://msdn.microsoft.com/msdnmag/issues/05/10/TestRun/default.aspx) After a while, I had to find an issue I couldn't solve. (Of course) If an ASP.NET page uses the smartnav option, the document you get from IE only contains...
0
1230
by: geertm | last post by:
Hello, I have a problem accessing frames using the MSHTML object. I tried this code ----------------------------------- For intindex = 0 To objDoc.frames.count - 1 .... Next -----------------------------------
8
7972
by: kaaposc | last post by:
Hello! This is not question, I was just wondering, why people continue using frames and iframes when we have handy AJAX approach to fill needed divs with content. Is it because of some user's paranoia about javascript? But if they make pages without javascript, they would not need to bother, how to access other frame's content, would they?...
14
7035
by: Mark | last post by:
Hi Guys, I am very new to ASP.NET world. I need to create three frames. One at the top, one on the left and another on the right side. I don't know how to do it. So please help me with it. I'll appreciate any help/example you can provide. I am using visual studio 2005. Thanks, Mark
0
7815
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7433
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7763
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5340
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4949
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1891
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1020
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
712
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.