IHTMLDocument3、IHTMLInputElement 操作

void CWebDlg::OnOK()
{
 IDispatch* pIDis = NULL;
 pIDis = m_web.GetDocument();
 if (pIDis != NULL) {
  IHTMLDocument3* pdoc = NULL;;
  pIDis->QueryInterface(IID_IHTMLDocument3,(void**)&pdoc);
  IHTMLElement* pElement = NULL;
  BSTR v;
  v = L"su";
  pdoc->getElementById(v,&pElement); //这里的 v 可以换为 L"su";
  IHTMLInputElement* pInput = NULL;
//这里可以使用ATL智能指针真接赋值;CComQIPtr< IHTMLInputElement  > spInputElement = pElement;
  pElement->QueryInterface(IID_IHTMLInputElement,(void**)&pInput); 
  BSTR pText;
  pInput->get_value(&pText);
  AfxMessageBox(CString(pText));
 }
}

posted @ 2011-12-31 18:45  stma  阅读(2759)  评论(0)    收藏  举报