【问题标题】:TWebbrowser / TEmbeddedWb : hide all messageboxesTWebbrowser / TEmbeddedWb : 隐藏所有消息框
【发布时间】:2014-12-11 11:47:32
【问题描述】:

我有一个使用 TEmbeddedWb 自动执行数据抓取任务的应用程序。

当我的应用导航到某些网站时,它会显示消息/弹出框,这会使过程变慢。

我想阻止 TWebbrowser 可以显示的任何消息框。

我已经将 'silent' 属性设置为 true,并将 onshowmessage 方法设置如下,但仍然显示消息框。有什么提示吗?

 function TForm1.webShowMessage(Sender: TObject; HWND: Cardinal; lpstrText,
 lpstrCaption: PWideChar; dwType: Integer; lpstrHelpFile: PWideChar; dwHelpContext: Integer;
 var plResult: Integer): HRESULT;
 begin
 plresult := S_OK;
 end;

【问题讨论】:

    标签: delphi twebbrowser tembeddedwb


    【解决方案1】:

    我可以通过对 TEmbeddedWb 源代码进行一些更改来完成这些任务,特别是在下面的函数上:

     procedure TEmbeddedWB.HandleDialogBoxes(var AMsg: Messages.TMessage);
    

    这里是变化:

     DlgClss := GetWinClass(PopHandle);
     WinClss := GetWinClass(Windows.GetParent(PopHandle));
     DlgCaption := GetWinText(PopHandle);
     if (DlgClss = 'Internet Explorer_TridentDlgFrame') or ((DlgClss = '#32770'))
       // comment here to make all windows be evaluated
       {and (WinClss <> 'TApplication') and
       (FindControl(Windows.GetParent(PopHandle)) = nil))}
       then
     begin
       if (WinClss = 'TApplication') or (FindControl(Windows.GetParent(PopHandle)) <> nil) then
         begin
         if pos('web browser',lowercase(DlgCaption)) = 0 then
           exit;
         end;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-04
      相关资源
      最近更新 更多