12-22-2005 07:58 AM
12-27-2005 06:04 PM
12-28-2005 12:40 AM
Hi Sarah,
Thanks for the reply..
I tried accessing frames in CVI and then the forms in the particular frame...Mr. Andy(Application engineer) supported me a lot...i have the following problem in CVI which i have listed:
I got errors in IHTMLElementcollection.item function in CVI..
below is the definations and functions i used:
HRESULT status;
VARIANT vCStr;
VARIANT element;
static MSHTMLObj_IHTMLFramesCollection2 pFramesCol;
static MSHTMLObj_IHTMLElementCollection formsHandle;
static MSHTMLObj_IHTMLDocument2 doc;
static CAObjHandle pHandle;
MSHTML_IHTMLDocument2Getframes (docHandle, NULL, &framesHandle);
MSHTML_IHTMLFramesCollection2Getlength (framesHandle, NULL, &numFrames);
status = CA_VariantSetCString (&vCStr, "FRAME NAME");
HTML_IHTMLFramesCollection2item (framesHandle, NULL, vCStr, &vCStr1);
status = MSHTML_IHTMLWindow2Getframes (framesHandle,NULL,&pFramesCol);
status = MSHTML_IHTMLWindow2Getdocument (framesHandle,NULL , &doc);
status = MSHTML_IHTMLDocument2Getforms (doc, NULL, &formsHandle);
status = CA_VariantSetCString (&element, "FORM NAME");
status = MSHTML_IHTMLElementCollectionitem(formsHandle,NULL,element,CA_DEFAULT_VAL, &pHandle);
I implemented the above code from the following ex:(for getting a reference to the frame document)
// Assume pWin is a valid IHTMLWindow interface pointer for the main window
VARIANT frameRequested;
VARIANT frameOut;
IHTMLFramesCollection2* pFramesCol;
IHTMLWindow2* pRightFrameWindow;
IHTMLDocument2* pRightDoc;
frameRequested.vt = VT_BSTR;
frameRequested.bstrVal = L"rightframe";
hr = pWin->get_frames(&pFramesCol);
hr = pFramesCol->item(&frameRequested, &frameOut);
hr = frameOut.pdispVal->QueryInterface(IID_IHTMLWindow2, (void**)&pRightFrameWindow);
hr = pRightFrameWindow->get_document(&pRightDoc);
i checked the status and the handles in debug mode..and everything was ok except the MSHTML_IHTMLElementCollectionitem
12-29-2005 09:36 AM
Hi Vevek,
I don't know if you received this very useful attachment from Sarah or not. It’s a great example using the Microsoft HTML Object Library. This should help give you ideas and assist you in building your application.
Hope this helps!
Best Regards,
12-29-2005 11:41 AM
Hi Jonathan,
Thanks for the code. But it was already shared by Andy. In the code the number of frames in a particular page was displayed but for me
i need to go a form in a particular frame in a page..I have written the code but had problems in IHTMLElementcollection.items functions
which i have mentioned in the previous mail in detail..and i need to know whether the functions is implmented correctly or not!!and also the code..
Andy has previously implemented an ex in labview for search in google(doesn't involve frames but only forms)
i tried it in CVI but got some problems in IHTMLElementcollection.items..functions
please let me know ...the results
i am trying the same in VC++ also..
regards
vevek
12-29-2005 04:26 PM
Hi vevek,
I have been looking at your code as well as fooling around with the code I sent you. I am know getting the same pHandle return value you were, which apparently according to Microsoft’s website indicates the element was not found and the call was not successful. I believe we are calling the functions properly, but perhaps are missing something basic in terms of the correct flow of using these function calls.
It appears now that we heading into deep Microsoft territory. Below is the main link on Microsoft's website to the ElementCollection object. From here you can view the item method, learn about the correct parameters (such as the name which needs to be categorized under the all collection), and view much more information.
IHTMLElementCollection Interface
I would suggest taking a look around at these documents as they seem to provide great references into the functions you are trying to use. If after looking at these documents you are still having trouble, let us know. Also, if you do have some trouble, tell us which webpage you are testing the code on so we can be on the same page.
Hope this helps!
Best Regards,
07-17-2006 10:22 AM
hi,
i know i am replying to this thread after a long time.. but i am having the same problem with frames in CVI.
1.I used IE activeX.
2. i got document IUnknown interface pointer from the ie Handle.
SHDocVw_GetProperty (ieHandle, 0, SHDocVw_IWebBrowser2Document, CAVT_UNKNOWN, &pUnk);
3.i got the document object from interface pointer
status=pUnk->lpVtbl->QueryInterface (pUnk,&IID_IHTMLDocument2, (void *)&document);
4.i got frames collection after that.
document->lpVtbl->get_frames(document,&pElem);
5. i was able to get the no of frames after that
pElem->lpVtbl->get_length(pElem,&leng);
6.I got the document object for the IHTMLWindow2
VARIANT ci,cl;
IHTMLWindow2 pWindow;
ci.n1.n2.vt=VT_UINT;
ci.n1.n2.n3.lVal=i;
pElem->lpVtbl->item(pElem,&ci,&cl);
status=cl.n1.n2.n3.pdispVal->lpVtbl->QueryInterface(cl.n1.n2.n3.pdispVal,&IID_IHTMLWindow2,(LPVOID*)&pWindow);
status=pWindow->lpVtbl->get_document(pWindow,(void *)&document1);
After this step, i tried to iterate throug the frames.i success fully went through the first frame which is 'MAIN'
but i was not able to get the document object for the second frame.i am getting the same document object again and again.
i dont get what i am doing wrong.
regards,
Radha R
07-18-2006 05:16 PM