96 lines
3.0 KiB
C#
96 lines
3.0 KiB
C#
/**
|
|
*mpv.net
|
|
*Copyright(C) 2017 stax76
|
|
*
|
|
*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.Drawing;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace mpvnet
|
|
{
|
|
public class Native
|
|
{
|
|
[DllImport("kernel32.dll")]
|
|
public static extern IntPtr LoadLibrary(string dllToLoad);
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
|
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
|
public static extern string SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
|
|
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
|
public static extern bool PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern void ReleaseCapture();
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern bool AdjustWindowRect(ref RECT lpRect, uint dwStyle, bool bMenu);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern IntPtr GetWindowLongPtrW(IntPtr hWnd, int nIndex);
|
|
|
|
[DllImport("user32.dll", SetLastError = true)]
|
|
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct RECT
|
|
{
|
|
public int Left;
|
|
public int Top;
|
|
public int Right;
|
|
public int Bottom;
|
|
|
|
public RECT(Rectangle r)
|
|
{
|
|
Left = r.Left;
|
|
Top = r.Top;
|
|
Right = r.Right;
|
|
Bottom = r.Bottom;
|
|
}
|
|
|
|
public RECT(int left, int top, int right, int bottom)
|
|
{
|
|
Left = left;
|
|
Top = top;
|
|
Right = right;
|
|
Bottom = bottom;
|
|
}
|
|
|
|
public Rectangle ToRectangle()
|
|
{
|
|
return Rectangle.FromLTRB(Left, Top, Right, Bottom);
|
|
}
|
|
|
|
public Size Size
|
|
{
|
|
get { return new Size(Right - Left, Bottom - Top); }
|
|
}
|
|
|
|
public int Width
|
|
{
|
|
get { return Right - Left; }
|
|
}
|
|
|
|
public int Height
|
|
{
|
|
get { return Bottom - Top; }
|
|
}
|
|
}
|
|
}
|
|
} |