C#ChromiumWebBrowser:从偷焦点预防控制 [英] C# ChromiumWebBrowser: Prevent control from stealing focus

查看:3099
本文介绍了C#ChromiumWebBrowser:从偷焦点预防控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有过很多类似的问题,但没有解决我的问题。



我这样做,有一个表格,在它ChromiumWebBrowser的程序。导航是自动完成的。当web浏览器完成它的任务,我会处理掉它,创建一个新的浏览器,添加形成,并加载一个新的地址。



不过,新的web浏览器中创建并添加到形成时,程序跳转在以往其他程序是与重点顶端什么前面。例:我开始我的程序,按下按钮,启动了它的任务,打开记事本,输入一些文本并导航到一个新的站点时,我的程序在它面前跳



即使程序最小化时,不要在字体跳,但还是抢断焦点,而没有程序具有焦点。



请帮帮我!非常感谢


解决方案

  1. 您需要的表格设置:this.Topmost = FALSE;
    和刚才设置:this.BringToFront();


  2. 新的浏览器添加到窗体就像函数如下:



    私人ChromiumWebBrowser AddNewBrowser(FATabStripItem标签栏,字符串URL)
    {
    如果(URL ==)
    {
    URL =的OpenURL;
    txtUrl.Select();
    txtUrl.Focus();
    }
    ,否则
    {
    tabStrip.Select();
    tabStrip.Focus();
    }

      ..................... .. 
    .......................
    ................. ......

    }




希望有帮助到您。谢谢!


There have been many similar questions, but not solved my problem.

I'm doing a program that has a Form with a ChromiumWebBrowser in it. The navigation is done automatically. When webbrowser complete it's task, I'll dispose it, create a new webbrowser, add it to form, and load a new address.

But, when the new webbrowser was created and added to form, the program jumps in front of what ever other program is in the top with focus. Example: I start my program, press the button to start its task, open notepad to type some text and my program jumps in front of it when navigating to a new site.

Even when program was minimized, it don't jump in font of, but still steals focus, and no program has focus.

Please help me! Thanks alot!

解决方案

  1. Your Form need set: this.Topmost = false; AND just set: this.BringToFront();

  2. Add new browser to the form just like the function as follow:

    private ChromiumWebBrowser AddNewBrowser(FATabStripItem tabStrip, String url) { if (url == "") { url = OpenUrl; txtUrl.Select(); txtUrl.Focus(); } else { tabStrip.Select(); tabStrip.Focus(); }

            .......................
            .......................
            .......................
    
       }
    

Hope has help to you. Thanks !

这篇关于C#ChromiumWebBrowser:从偷焦点预防控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆