mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-10 17:29:08 +00:00
120 lines
4.7 KiB
C#
120 lines
4.7 KiB
C#
// Copyright © 2017 Paddy Xu
|
|
//
|
|
// This file is part of QuickLook program.
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
using System;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using QuickLook.Common.Helpers;
|
|
|
|
namespace QuickLook.Common.NativeMethods
|
|
{
|
|
public static class User32
|
|
{
|
|
public delegate int KeyboardHookProc(int code, int wParam, ref KeyboardHookStruct lParam);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern int MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight,
|
|
[MarshalAs(UnmanagedType.Bool)] bool bRepaint);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy,
|
|
uint uFlags);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern IntPtr SetWindowsHookEx(int idHook, KeyboardHookProc callback, IntPtr hInstance,
|
|
uint threadId);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern bool UnhookWindowsHookEx(IntPtr hInstance);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern int CallNextHookEx(IntPtr idHook, int nCode, int wParam, ref KeyboardHookStruct lParam);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern IntPtr GetForegroundWindow();
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern IntPtr GetWindowThreadProcessId(IntPtr hWnd, IntPtr processId);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern IntPtr GetWindowThreadProcessId(IntPtr hWnd, out uint processId);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern IntPtr AttachThreadInput(IntPtr idAttach, IntPtr idAttachTo, bool fAttach);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern IntPtr GetFocus();
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
|
public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern IntPtr GetParent(IntPtr hWnd);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern int SetWindowCompositionAttribute(IntPtr hwnd,
|
|
ref WindowHelper.WindowCompositionAttributeData data);
|
|
|
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
|
public struct KeyboardHookStruct
|
|
{
|
|
public int vkCode;
|
|
public int scanCode;
|
|
public int flags;
|
|
public int time;
|
|
public int dwExtraInfo;
|
|
}
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
public static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
|
|
public static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
|
|
public static readonly IntPtr HWND_TOP = new IntPtr(0);
|
|
public static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
|
|
|
|
public const uint SWP_NOSIZE = 0x0001;
|
|
public const uint SWP_NOMOVE = 0x0002;
|
|
public const uint SWP_NOZORDER = 0x0004;
|
|
public const uint SWP_NOREDRAW = 0x0008;
|
|
public const uint SWP_NOACTIVATE = 0x0010;
|
|
public const uint SWP_DRAWFRAME = 0x0020;
|
|
public const uint SWP_FRAMECHANGED = 0x0020;
|
|
public const uint SWP_SHOWWINDOW = 0x0040;
|
|
public const uint SWP_HIDEWINDOW = 0x0080;
|
|
public const uint SWP_NOCOPYBITS = 0x0100;
|
|
public const uint SWP_NOOWNERZORDER = 0x0200;
|
|
public const uint SWP_NOREPOSITION = 0x0200;
|
|
public const uint SWP_NOSENDCHANGING = 0x0400;
|
|
public const uint SWP_DEFERERASE = 0x2000;
|
|
public const uint SWP_ASYNCWINDOWPOS = 0x4000;
|
|
|
|
public const int WH_KEYBOARD_LL = 13;
|
|
public const int WM_KEYDOWN = 0x100;
|
|
public const int WM_KEYUP = 0x101;
|
|
public const int WM_SYSKEYDOWN = 0x104;
|
|
public const int WM_SYSKEYUP = 0x105;
|
|
public const int GWL_EXSTYLE = -20;
|
|
public const int WS_EX_NOACTIVATE = 0x08000000;
|
|
// ReSharper restore InconsistentNaming
|
|
}
|
|
} |