怎么象关别的程序一样关ie窗口(50分)

  • 主题发起人 主题发起人 jps_exp
  • 开始时间 开始时间
J

jps_exp

Unregistered / Unconfirmed
GUEST, unregistred user!
我想关闭一个ie的窗口,用了几个方法,都不能关,<br>不过关别程序都可以。
 
[:(]怎么没人帮我
 
你用的什么方法?<br>如果是写在网页里面的,可以用JavaScript
 
你找到那个IE窗口的句柄,然后用<br>PostMessage(handle,WM_CLOSE,0,0); 来关掉.<br>其中handle是该IE的句柄.
 
简单,看看下面的回答,有问题再说<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=635843
 
每个IE的运行实例都可以通过IWebBrowser2接口来取得,然后就可以调用此接口的涵数来<br>控制IE的"行动"啦:),如下:<br>var idisp : IDispatch;<br>&nbsp; &nbsp; iwb2 &nbsp;: IWebBrowser2;<br>&nbsp; &nbsp; shellWindows : IShellWindows;<br>&nbsp; &nbsp; i : integer;<br>&nbsp; &nbsp; hwnd : THandle;<br>&nbsp; &nbsp; drawCanvas : TCanvas;<br>&nbsp; &nbsp; yes : wordbool;<br>begin<br>&nbsp; &nbsp; shellWindows := CoShellWindows.Create();<br>&nbsp; &nbsp; for i := 0 to shellWindows.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; idisp := shellWindows.Item( i );<br>&nbsp; &nbsp; &nbsp; &nbsp; idisp.QueryInterface( IWebBrowser2 , iwb2 );<br>&nbsp; &nbsp; &nbsp; &nbsp; if ( iwb2 &lt;&gt; nil ) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iwb2.Set_Left( iwb2.Get_Left() + 2 );<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iwb2.Set_RegisterAsBrowser(true);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;except<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;On E : Exception do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ShowMessage('No page to go or forward');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>end;
 
[:)]我来给分了
 
后退
顶部