diff --git a/src/Misc/CorePlayer.cs b/src/Misc/CorePlayer.cs index 20521d8..328eb9a 100644 --- a/src/Misc/CorePlayer.cs +++ b/src/Misc/CorePlayer.cs @@ -346,8 +346,19 @@ namespace mpvnet mpv_event evt = (mpv_event)Marshal.PtrToStructure(ptr, typeof(mpv_event)); if (WindowHandle == IntPtr.Zero) + { WindowHandle = Native.FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null); + int GWL_STYLE = -16; + uint WS_CHILD = 0x40000000; + uint WS_VISIBLE = 0x10000000; + uint WS_DISABLED = 0x08000000; + uint WS_CLIPSIBLINGS = 0x04000000; + + Native.SetWindowLong(WindowHandle, GWL_STYLE, + WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CLIPSIBLINGS); + } + try { switch (evt.event_id) diff --git a/src/Misc/GlobalHotkey.cs b/src/Misc/GlobalHotkey.cs index 118cc6f..53e0f35 100644 --- a/src/Misc/GlobalHotkey.cs +++ b/src/Misc/GlobalHotkey.cs @@ -61,9 +61,6 @@ namespace mpvnet int hi = result >> 8; int lo = result & 0xFF; - if (lo == -1 || hi == -1) - return; - vk = lo; if ((hi & 1) == 1) mod |= KeyModifiers.Shift; diff --git a/src/Native/Native.cs b/src/Native/Native.cs index 2ba9dbf..a225805 100644 --- a/src/Native/Native.cs +++ b/src/Native/Native.cs @@ -68,6 +68,20 @@ namespace mpvnet return GetWindowLong32(hWnd, nIndex); } + [DllImport("user32.dll", EntryPoint = "SetWindowLong")] + public static extern IntPtr SetWindowLong32(IntPtr hWnd, int nIndex, uint dwNewLong); + + [DllImport("user32.dll", EntryPoint = "SetWindowLongPtr")] + public static extern IntPtr SetWindowLong64(IntPtr hWnd, int nIndex, uint dwNewLong); + + public static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong) + { + if (IntPtr.Size == 8) + return SetWindowLong64(hWnd, nIndex, dwNewLong); + else + return SetWindowLong32(hWnd, nIndex, dwNewLong); + } + [DllImport("gdi32.dll")] public static extern int GetDeviceCaps(IntPtr hdc, int nIndex);