0

我有一个使用 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;
4

1 回答 1

0

我可以通过对 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;
于 2014-12-11T13:28:28.833 回答