AxAcroPDF swallows the keys, how to make it stop?

AxAcroPDF swallows all key-related events as soon as it receives focus, including shortcuts, keystrokes, etc. I added a message filter, and it also does not receive any messages related to keys. This is a COM component, can it be relevant?

Is there a way to catch them before the control swallows them?

+3
source share
4 answers

Hans is right, Acrobat Reader spawns two AcroRd32 child processes with which you do not have direct access from your managed code.

I experimented with this, and you have three viable options:

  • , / WM_SETFOCUS, AcroRd32. # , , : http://www.codeproject.com/KB/system/WilsonSystemGlobalHooks.aspx

    , AcroRd32. , , , , .

  • PDF. . : .net PDF : http://www.codeproject.com/KB/applications/PDFViewerControl.aspx

  • . , , (, ):

    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 < 1)
            listBox1.Focus();
    }
    
+4

, , . .

, , ( acropdf ), ( ). .

, (acropdf) , ( )

AxAcroPDF_this.Enabled = False AxAcroPDF_this.src= m_src

, , 1 .

AxAcroPDF_this.Enabled = False

, , Windows, acropdf , , Windows ( ).

, , - . , , , .

+4

COM , . Windows SDK, SetParent(). , acroread.exe , .

SetWindowsHookEx(), DLL WH_GETMESSAGE. ​​DLL #.

, . , .

+2

- , AxAcroPDF , . "" .

, AxAcroPDF GroupBox. PDF, , GroupBox Enabled False .

+1

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


All Articles