Question on IHTMLFrameBase2
Posted: Fri Oct 14, 2005 10:53 pm
I've got a frames collection pointer and am trying to loop through the frames and get a reference to the ITHMLDocument2 within it.
Here's the code:
So I'm trying to get a pointer to a frame object in order to get the pointer to the IHTMLDocument2 object within it in order to access it's contents.
Freak posted an example that uses IHTMLFrameBase2 but it gets to it by looping through the tags and finding the <Frame> or <IFrame> tags and then retrieving the IHTMLFrameBase2 reference.
What am I missing? Help!
Here's the code:
Code: Select all
If Document\get_parentWindow(@xWindow.IHTMLWindow2) = #S_OK
If xWindow\get_frames(@FramesCollection.IHTMLFramesCollection2_FIXED) = #S_OK
; read the number of elements in this collection
;
FramesCollection\get_length(@Total2)
Debug "Number of Frames: "+Str(Total2)
For index2 = 0 To Total2-1
varIndex2.VARIANT_SPLIT\VAriant\vt = #VT_I4
varIndex2\VAriant\lVal = index
xFrameElementDispatch.IDispatch = 0
If FramesCollection\item(@varindex2, @xFrameElementDispatch.IDispatch) = #S_OK
If xFrameElementDispatch ; must check this value according to the docs, as even on failure, #S_OK is returned
; This next line does not work - invalid memory access
If xFrameElementDispatch\QueryInterface(?IID_IHTMLFrameBase2, @xBaseDispatch.IHTMLFrameBase2 )= #S_OK
If xBaseDispatch\get_contentWindow(@Document2.IHTMLDocument2)
Freak posted an example that uses IHTMLFrameBase2 but it gets to it by looping through the tags and finding the <Frame> or <IFrame> tags and then retrieving the IHTMLFrameBase2 reference.
What am I missing? Help!