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)
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!
When all is said and done, more is said than done.
the second argument to FramesCollection\item() must be a VARIANT pointer too.
So pass a pointer to an empty VARIANT structure there, and after a sucessfull
return, the pDispVal member of the structure holds the IDispatch pointer, or 0 on failure.
It crashes at the later line because you do not receive the correct pointer in this call.
varIndex2.VARIANT_SPLIT\VAriant\vt = #VT_I4
varIndex2.VARIANT_SPLIT\VAriant\lVal = index
varIndex3.VARIANT_SPLIT
xFrameElementDispatch.IDispatch = 0
If FramesCollection\item(@varIndex2, @varIndex3) = #S_OK
If varIndex3.VARIANT_SPLIT\VAriant\pdispVal ; this shows a long value
xFrameElementDispatch.IDispatch = @varIndex3.VARIANT_SPLIT\VAriant\pdispVal ; not sure if I'm using this correctly?
If xFrameElementDispatch\QueryInterface(?IID_IHTMLWindow2, @Document2.IHTMLDocument2 )= #S_OK ;This gives an error
HookLinks(Document2.IHTMLDocument2)
EndIf
EndIf
EndIf
I just haven't gotten the hang of these variants, idispatch, etc. But I did buy a C++ book called "Thinking in C++" which seems to be pretty good but there's nothing like learning under fire. Thanks again in advance.
When all is said and done, more is said than done.