我在程序中有IHTMLWindow4(WebBrowser1.Document).focus;
编译时报错:[Error] Main.pas(281): Undeclared identifier: 'IHTMLWindow4'
我已经uses中加了ActiveX并且用OleInitialize(nil)和OleUninitialize进行了初始化,为什么还不行呢?

解决方案 »

  1.   

    重新导入mshtml_tlb
    ((Document as IHTMLDocument2).parentWindow as IHTMLWindow4).focus;
      

  2.   

    对Eastunfail: 
    我已经uses了MSHTML,编译后还是
    [Error] Main.pas(281): Undeclared identifier: 'IHTMLWindow4'
    [Error] Main.pas(281): Missing operator or semicolon对westfly:
    请教重新导入mshtml_tlb具体是什么意思呢?该怎么操作呢?
      

  3.   

    delphi自带的mshtml单元(出得比较早)只支持到2,你重新从system32目录下对mshtml.dll导入一遍即可。
      

  4.   

    project->import type library
      

  5.   

    westfly:
      我是在XP下跑的Delphi 7,我将system32下的mshtml.dll导入时出现如下错误:
    一个错误提示框,“Error loading type library/DLL”.
    程序还是编译通不过。
      

  6.   

    OleObject.document.parentWindow.focus()
      

  7.   

    西翔朋友:
      还是不行,WebBrowser1.Document就没有ParentWindow属性。
    编译错误为:
    [Error] Main.pas(283): Undeclared identifier: 'ParentWindow'
    [Error] Main.pas(283): Missing operator or semicolon大家都来救命呀!!!
      

  8.   

    看清楚:不是"WebBrowser1.Document.ParentWindow"
    WebBrowser1.OleObject.document.parentWindow.focus()
      

  9.   

    例如:将焦点移动到一个按钮上(IHTMLDocument2(WebBrowser1.Document).all.item('按钮名',0) as IHTMLInputButtonElement).focus()
      

  10.   

    Eastunfail朋友:
      由于WebBrowser1中的页面是随时可能变化的,因此无法知道按钮名,有没有办法将焦点设置在任一页面的任一个可接受焦点的控件上呢?(比如Tab将停留的页面中第一个控件)