找不到是正常的。那些东西只能通过IHTMLDocument2指针去获得。除非你要找的是一个ActiveX控件的窗口。

解决方案 »

  1.   

    难道ie里的字窗口不是windows HWND吗?
      

  2.   

    ComboBox的类名我是通过spy++得到的,所以我想应该是正确的啦。
    sxbyl(白菜.NET) 能不能介绍一下IHTMLDocument2指针呢?我没有接触过。
    sorry2000(方言),不仅仅是ie里面的得不到,好象比如vc界面下的也得不到,是findwindowex不好用吗?
      

  3.   

    IHTMLDocument2相关的东西你可以看MSDN,介绍得很详细。
    用IHTMLDocument2的get_all可以得到IHTMLElementCollection指针,通过IHTMLElementCollection的item可以得到一个对象的指针
    下面是我的一个函数
    void CSendMsgDlg::PutIEText(IHTMLElementCollection *pobjAllElement,CString strName,CString strText)
    {
    CComPtr<IDispatch>pDisp;
    pobjAllElement->item(COleVariant(strName),COleVariant((long)0),&pDisp);
    CComQIPtr<IHTMLInputTextElement, &IID_IHTMLInputTextElement>pElement;
    if(pDisp==NULL)
    {
    AfxMessageBox(strName + "没有找到!");
    }
    else
    {
    pElement=pDisp;
    pElement->put_value(strText.AllocSysString());
    }
    }
      

  4.   

    我刚才看了看111222的文档,里面有用findwindowex的方法,大家去看看吧,
    sxbyl(白菜.NET) 你说的方法是需要有com的   知识吧,我还没有学过,可能需要一段时间来看看。
      

  5.   

    有个不明白的地方,为什么combobox可以是一个ComboBoxEx的子窗口呢?
      

  6.   

    BOOL FindIeURL()
    {HWND hWorker,hRebar,hComEx,hcom,hEdit;
    HWND hwndParent=::FindWindow("IEFrame",NULL);//找到最近的IE,要是找到某个IE需要枚举所有的IE过筛子
    if(hwndParent == NULL)//没有IE运行中
    return FALSE;
    char szURL[260]; 
    hWorker=FindWindowEx(hwndParent,0,"WorkerA",NULL);//找到工作区
    if(hWorker == NULL)//用户用NT
    hWorker=FindWindowEx(hwndParent,0,"WorkerW",NULL);//WindowNT中的iehRebar=FindWindowEx(hWorker,0,"ReBarWindow32",NULL);//找到RebarhComEx=FindWindowEx(hRebar,0,"ComboBoxEx32",NULL);//找到Comboboxex
    hcom=FindWindowEx(hComEx,0,"ComboBox",NULL);//找到comboboxhEdit=FindWindowEx(hcom,0,"Edit",NULL);//找到ComBoBox的edit控件句柄 
    ::SendMessage(hEdit,WM_GETTEXT,260,(LPARAM) szURL);AfxMessageBox(szURL);
    return TRUE;
    }
      

  7.   

    好像微软的MSDN里面有篇文章介绍从HWND怎么获得IWebBrowser接口的。
    有了IWebBrowser接口,你就可以通过DOM访问里面的元素。访问方式基本和脚本一样,比如Windows.document.all.itemID.innerText等等,只不过换成了相应COM接口的方法的调用。
      

  8.   

    以前我遇到过这道题,正好回答你.不知道你想做什么, 我关注,做好后给我一份.  :)
    CWnd *pIEWnd;HWND hChild;   //IE 地址栏句柄 UpdateData();m_WindowTitle = "http://student.tsinghua.edu.cn/ - Microsoft Internet Explorer";pIEWnd = CWnd::FindWindow(NULL,m_WindowTitle);if (pIEWnd == NULL){ MessageBox("Can`t Find the specified Window"); return; }                                          MessageBox("Get the Father Window!!!");            hChild=FindWindowEx(pIEWnd,0,"ReBarWindow32",NULL);       hChild=FindWindowEx(hChild, 0,"ComboBoxEx32",NULL);       hChild=FindWindowEx(hChild, 0,"ComboBox",NULL);       hChild=FindWindowEx(hChild, 0,"Edit",NULL); SendMessage(pIEWnd,WM_SYSCOMMAND,SC_MAXIMIZE,NULL);  //最大化IE窗口 SetForegroundWindow(pIEWnd);  //设置为当前窗口 SendMessage(hChild,WM_CHAR,'a',NULL);HWND hCombo = ::FindWindowEx(pIEWnd-> GetSafeHwnd(),NULL,"ComboBox",NULL); if (hCombo == NULL){MessageBox("Can`t find the ComboBox"); return; }MessageBox("Get the ComboBox!!!"); 哈哈,该送分了:)
      

  9.   

    请关注:
    http://www.csdn.net/expert/topic/411/411075.shtm
    分数为150分
    十万火级,如能给出答案,再送300分
      

  10.   

    可乐瓶的方法是最佳的, 可是如果没有Rebar, Combobox等, 又如何得到IE 访问的URL 呢?
      

  11.   

    去看看http://www.csdn.net/expert/topic/360/360785.shtm