Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Hans is correct, the Acrobat Reader spawns two child AcroRd32 processes which you have no direct access to from within your managed code.</p> <p>I have experimented with this and you have three viable options:</p> <ol> <li><p>You can create a <strong>global system hook</strong>, and then look for and filter out / respond to WM_SETFOCUS messages sent to your child AcroRd32 windows. You can accomplish some of this from within C# by using a wrapper library, such as the one here: <a href="http://www.codeproject.com/KB/system/WilsonSystemGlobalHooks.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/system/WilsonSystemGlobalHooks.aspx</a></p> <p>You also need to identify the correct processes as there may be more than one instance of your application, or other instances of AcroRd32. This is the most deterministic solution, but because your application will now be filtering messages sent to every single window in existence, I generally don't recommend this approach because then your program could negatively affect system stability.</p></li> <li><p>Find an <strong>alternate PDF viewing control</strong>. See this answer for a few commercial components: <a href="https://stackoverflow.com/questions/5196989/net-pdf-viewer-control">.net PDF Viewer control</a> , or roll your own: <a href="http://www.codeproject.com/KB/applications/PDFViewerControl.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/applications/PDFViewerControl.aspx</a></p></li> <li><p>Find an <strong>acceptable hack</strong>. Depending on how robust your application needs to be, code such as the following may be suitable (it was suitable for my case):</p> <pre><code>DateTime _lastRenav = DateTime.MinValue; public Form1() { InitializeComponent(); listBox1.LostFocus += new EventHandler(listBox1_LostFocus); } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { axAcroPDF1.src = "sample.pdf"; //this will cause adobe to take away the focus _lastRenav = DateTime.Now; } void listBox1_LostFocus(object sender, EventArgs e) { //restores focus if it were the result of a listbox navigation if ((DateTime.Now - _lastRenav).TotalSeconds &lt; 1) listBox1.Focus(); } </code></pre></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload