VC WebBrowser2 关于设置textarea(有iframe嵌入)的有关问题

VC WebBrowser2 关于设置textarea(有iframe嵌入)的问题
VS2010的 (由VC6自动转换过来)

现在想控制输入网页的textarea控件,一般是没问题的,但现在用到的Z-Blog中的发布新文章时,那个正文是有iframe的,好像无法直接输入数据。
也找了一些****相关的问题和程序,不过还是不行,求各位高手帮忙(在做站群管理系统)




// 输入正文
Sleep(1);
varID=COleVariant("txaContent");//控件的ID
hr=pColl2->item(&varID, &varIndex);// 获取指定ID控件的位置
IHTMLTextAreaElement *pElemTextArea = NULL;
hr=pDisp2->QueryInterface(IID_IHTMLTextAreaElement,(void**)&pElemTextArea);//调用QueryInterface获取控件元素接口
CString strText("测试:正文输入成功");
BSTR pTextArea = strText.AllocSysString();
hr = pElemTextArea->put_value(pTextArea);




上面这种方案肯定不行




HRESULT hr;
IDispatch *pDisp;
pDisp=m_ctrlWeb.GetDocument();//获取控件文档接口
IHTMLDocument2 *pDoc2;
hr=pDisp->QueryInterface(IID_IHTMLDocument2,(void**)&pDoc2);

IDispatch *pDisp2;
VARIANT varIndex;
varIndex.vt = VT_UINT;

int i = 0;
varIndex.lVal = i;//i控件的位置

IHTMLElementCollection *pColl=NULL;
hr=pDoc2->get_all(&pColl);// get_all()通过文档接口获取网页元素


CComBSTR tagName;
IHTMLElement *pElement;

VARIANT varID;
varID=COleVariant("MyEditor___Frame");//控件的ID
hr=pColl->item(varID, varIndex,&pDisp2);// 获取指定ID控件的位置
hr=pDisp2->QueryInterface(IID_IHTMLElement,(void**)&pElement);//调用QueryInterface获取控件元素接口
pElement->get_tagName(&tagName);

CString str = tagName;
str.MakeUpper();
if (str == "FRAME" || str == "IFRAME")
{
HRESULT hr; 
IHTMLWindow2 *pHTMLWindow;
IHTMLFrameBase2* pHTMLFrameBase2;
hr =pElement->QueryInterface(IID_IHTMLFrameBase2, (void**)&pHTMLFrameBase2);
pElement->Release();
hr = pHTMLFrameBase2->get_contentWindow(&pHTMLWindow);
pHTMLFrameBase2->Release();
hr = pHTMLWindow->get_document(&pDoc2);

// hr=pDoc2->get_all(&pColl);// get_all()通过文档接口获取网页元素
IHTMLFramesCollection2 *pColl2=NULL;
// hr=pDoc2->get_all(&pColl2);// get_all()通过文档接口获取网页元素
pDoc2->get_frames(&pColl2);


// 输入正文
Sleep(1);
varID=COleVariant("txaContent");//控件的ID
hr=pColl2->item(&varID, &varIndex);// 获取指定ID控件的位置
IHTMLTextAreaElement *pElemTextArea = NULL;
hr=pDisp2->QueryInterface(IID_IHTMLTextAreaElement,(void**)&pElemTextArea);//调用QueryInterface获取控件元素接口
CString strText("测试:正文输入成功");
BSTR pTextArea = strText.AllocSysString();
hr = pElemTextArea->put_value(pTextArea);

}





改成这种后好像也没输入进去,不知道为什么,可能是哪些获取没写吧。

------解决方案--------------------
VC WebBrowser2 关于设置textarea(有iframe嵌入)的有关问题
------解决方案--------------------
先要看你是否获取到iframe,然后是里面的控件,最后才是设置的问题