请问一下:
axWebBrowser控件里面如何禁止web网站的打印,上传和下载文件,
在axWebBrowser里面没有什么办法可以禁止到打印,上传和下载,
我想要求的效果是:
  用户一按网页的打印和上传,下载,就弹出MessageBox.Show的自定义禁止的消息框.而禁止打开“添加打印机的用户界面”,请问如何解决?希望提供代码。小弟感激不尽!

解决方案 »

  1.   

    有一个办法,就是定时器,0.1秒扫描一次窗口!        [DllImport("User32.dll", EntryPoint = "FindWindow", CharSet = CharSet.Auto)]
            public static extern int FindWindow(String className, String captionName);        [DllImport("user32.dll")]
            public static extern bool PostMessage(int hWnd, uint Msg, int wParam, int lParam);
    private void timerPopupWindows_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
    {
            this.Cursor=System.Windows.Forms.Cursors.Default;
                    KillPopupWindows();
    }
    private void KillPopupWindows()
    {   
    int hwnd_find=0;
    // check if we have any popup windows that we want to kill
    foreach (string windowTitle in this.htBannedWindows.Keys)
    {
    hwnd_find = FindWindow(null, windowTitle);
    if (hwnd_find != 0)
    {
    // close the window we found
    PostMessage(hwnd_find, WM_CLOSE, 0,0);
    }
    }
    }
      

  2.   

    要屏蔽的窗口列表可以写在xml文件中:<bannedWindows>
          <bannedWindow>
            <title>File Download</title>
            <message>测试1</message>
          </bannedWindow>
          <bannedWindow>
            <title>文件下载</title>
            <message>测试2</message>
          </bannedWindow>
          <bannedWindow>
            <title>发现新硬件</title>
            <message>测试2</message>
          </bannedWindow>
          <bannedWindow>
            <title>找到新的硬件向导</title>
            <message>测试2</message>
          </bannedWindow>
          <bannedWindow>
            <title>打印</title>
            <message>测试2</message>
          </bannedWindow>
          <bannedWindow>
            <title>print</title>
            <message>测试2</message>
          </bannedWindow>
          <bannedWindow>
            <title>Choose File</title>
            <message>测试2</message>
          </bannedWindow>
          <bannedWindow>
            <title>选择文件</title>
            <message>测试2</message>
          </bannedWindow>
      

  3.   

    title是窗口的标题,可以用于查找和关闭对应窗口。
    message可以用来在关闭后,提示一个自己的窗口信息,提示的内容,可以在xml文件中配置。
      

  4.   

    在webbrower中执行JS脚步
    屏蔽链接 this.WebBrowser1.AllowNavigation = false;   
    取消WebBrowser控件的NewWindow操作: