SASlions1 / jmm

Automatically exported from code.google.com/p/jmm
0 stars 0 forks source link

Keyboard hook is producing messaging events on a disposed form. #451

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The form is used by Mediaportal RefreshRate system and it's called 'SuicideForm'

Step to reproduce:

1) Enable Dynamic Refresh Rate on Media Portal 1.4.0

2) Play 2 o 3 movies that have different refresh rate (Ex 24fps)

Looking at the keyboard hook, on the sources right now.

Original issue reported on code.google.com by maximo.p...@nutzcode.com on 21 Jun 2013 at 10:41

GoogleCodeExporter commented 8 years ago
Okey, found the culprit, disabled right now:

CODE:

    void SubClass()
        {
            IntPtr hWnd = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
            NewWindowProc = new WindowProc(MyWindowProc);
            DefWindowProc = SetWindowLongPtr(hWnd, GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(NewWindowProc));
        }

        void UnSubClass()
        {
            IntPtr hWnd = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
            DefWindowProc = SetWindowLongPtr(hWnd, GWL_WNDPROC, DefWindowProc);
            DefWindowProc = IntPtr.Zero;
        }

        int MyWindowProc(System.IntPtr hWnd, int msg, int wParam, int lParam)
        {
            if (msg == WM_ACTIVATEAPP)
            {
                //disable keyboard hook if app is inactive
                // wParam=1 when activating, 0 when desactivating
                hook.IsEnabled = (wParam == 1);
            }

            return CallWindowProc(DefWindowProc, hWnd, msg, wParam, lParam);
        }

For some reasone, this SubClass. Makes or forwards the RefreshRate SucideForm 
Messages. The End Result, CallWndProc is probably forwarding Messages to a 
Disposed SucideForm.

Current Fix:

Commented Calls to SubClass end UnSubClass in the code.... Working fine...

Original comment by maximo.p...@nutzcode.com on 22 Jun 2013 at 12:07

GoogleCodeExporter commented 8 years ago
Cool, will take a look at this soon

Original comment by werndly...@gmail.com on 28 Jun 2013 at 12:00

GoogleCodeExporter commented 8 years ago
https://github.com/japanesemediamanager/animeplugin3/issues/12

Original comment by werndly...@gmail.com on 20 Aug 2014 at 12:27