Acrobat Reader ActiveX in the spotlight WebBrowser [C #]

I am using the webBrowser.Navigate(url) control to display the page.
I noticed that this action steals focus from the current control (grid), and I have a problem to focus the grid back (tired myGrid.Focus, .Select, etc.)

This is really annoying browser behavior ...

Does anyone know how to prevent the browser from stealing focus or (if not) to get the focus to control back?

EDIT:
I also tried the webBrowser.DocumentCompleted event to focus on the grid

EDIT 2
A good case for checking this is to open the PDF files webBrowser.Navigate(@"C:\TEMP\test.pdf") I think this is an ActiveX problem. At first glance, it seems that this is not a problem with focus control, but the loss of all the focus of the form ...

EDIT 3
I tried a different approach: the key key: Form event I think I can capture the keyPress form and transfer the focus from WebBrowser / AdobeReader ActiveX to my control. But surprisingly the event is not fired! Looks Reader gets all the control, and there is no way to do anything programmatically until you click on (at least) the form caption

Any recommendations (s)?

+4
source share
1 answer

As @nobugz said - it seems I found a side effect using the Adobe Reader ActiveX control.

I think I found a workaround for this. Not very elegant - but it works with me ... :)
Here's how I archive the focus control back using the Timer and the browser document Completed :

  private void webBrowser1_DocumentCompleted( object sender, WebBrowserDocumentCompletedEventArgs e ) { timer1.Interval = 100; timer1.Start(); } private void timer1_Tick( object sender, EventArgs e ) { if (this.textBox1.Focused) { timer1.Stop(); return; } this.textBox1.Focus(); } 
+3
source

Source: https://habr.com/ru/post/1304744/


All Articles