怎么自动点掉webbrowser的对话框,不是要直接禁止他出现,因为有时候要点确定有时候要点取消按钮的。
类似于delphi的
function CallBackProc(H, HMainForm: hwnd): Boolean; stdcall;  //用于自动点掉弹出窗口
var
  hChild : hwnd;
begin
  Result := True;
  if GetParent(H) = HMainForm then begin
    hChild := FindWindowEx(H, 0, PChar('Button'), PChar('确定'));
    if hChild > 0 then SendMessage(hChild, BM_Click, 0, 0);
  end;
end;大哥们能给出c#的代码吗?多谢啦

解决方案 »

  1.   

    你给出的Delphi代码是找到一个窗口句柄,然后发送消息的,网页的一些提示窗口,是用脚本alert()来显示的,这个不好弄。
      

  2.   


    但是delphi里面就能点掉网页的js对话框的啊,真的
      

  3.   

    http://topic.csdn.net/u/20090331/14/a81f5dc3-dfe7-4ce4-a3fb-b93f8d3c30fb.html
      

  4.   

    你试试看吧[DllImport("User32.dll", EntryPoint = "FindWindow")]
      private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
      [DllImport("User32.dll", EntryPoint = "SendMessage")]
      private static extern int SendMessage(  int hWnd,   // handle to destination window   int Msg,   // message   int wParam, // first message parameter   int lParam // second message parameter   ); 
    int WM_CLOSE = 0x010;
    string lpszParentWindow = "弹出窗体标题";
      int ParenthWnd = (int)FindWindow(null, lpszParentWindow);
      if (ParenthWnd != null)
      {
      //向系统发送关闭窗体指令
      int WndPr = SendMessage(ParenthWnd, WM_CLOSE, 0, 0);
      } 
      

  5.   


    这样试试看?
    public static int MK_MBUTTON = 0x0010;
    int WndPr = SendMessage(ParenthWnd, MK_MBUTTON , 0, 0);
      

  6.   


    大哥,这个是不是要配合 
    string lpszParentWindow = "弹出窗体标题";
      int ParenthWnd = (int)FindWindow(null, lpszParentWindow);
    的?有没有不需要匹配窗口标题的?出现对话框就按确定或取消的代码。多谢大哥解答啊
      

  7.   

    FindWindow里用对话框的类名就可以了lpClassName,用SPY++查看.
      

  8.   

    int ParenthWnd = (int)FindWindow("#32770 (对话框)",null);