delete redundant codes
This commit is contained in:
1 parent
c1d6e901b2
commit
e3d20382d4
8 files changed
+160
-541
No files matched your search
@@ -10,17 +10,12 @@ namespace HandyControl.Tools.Interop
|
||||
{
|
||||
internal class InteropMethods
|
||||
{
|
||||
private static int vsmNotifyOwnerActivate;
|
||||
|
||||
public static readonly IntPtr HRGN_NONE = new IntPtr(-1);
|
||||
internal static readonly IntPtr HRGN_NONE = new IntPtr(-1);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
internal static extern int RegisterWindowMessage(string msg);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||
internal static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, ref InteropValues.RECT lpPoints, uint cPoints);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||
internal static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.TBBUTTON lpBuffer,
|
||||
int dwSize, out int lpNumberOfBytesRead);
|
||||
@@ -282,18 +277,6 @@ namespace HandyControl.Tools.Interop
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr GetDC(IntPtr ptr);
|
||||
|
||||
internal static int NOTIFYOWNERACTIVATE
|
||||
{
|
||||
get
|
||||
{
|
||||
if (vsmNotifyOwnerActivate == 0)
|
||||
{
|
||||
vsmNotifyOwnerActivate = RegisterWindowMessage("NOTIFYOWNERACTIVATE{A982313C-756C-4da9-8BD0-0C375A45784B}");
|
||||
}
|
||||
return vsmNotifyOwnerActivate;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool GetWindowPlacement(IntPtr hwnd, InteropValues.WINDOWPLACEMENT lpwndpl);
|
||||
@@ -307,23 +290,6 @@ namespace HandyControl.Tools.Interop
|
||||
}
|
||||
throw new Win32Exception(Marshal.GetLastWin32Error());
|
||||
}
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern int GetSystemMetrics(int index);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern int TrackPopupMenuEx(IntPtr hmenu, uint fuFlags, int x, int y, IntPtr hwnd, IntPtr lptpm);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool EnableMenuItem(IntPtr menu, uint uIDEnableItem, uint uEnable);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern short GetKeyState(int vKey);
|
||||
|
||||
internal static bool IsKeyPressed(int vKey) => GetKeyState(vKey) < 0;
|
||||
|
||||
internal static IntPtr MakeParam(int lowWord, int highWord) => new IntPtr((lowWord & 65535) | highWord << 16);
|
||||
|
||||
internal static int GetXLParam(int lParam) => LoWord(lParam);
|
||||
|
||||
@@ -332,29 +298,14 @@ namespace HandyControl.Tools.Interop
|
||||
internal static int HiWord(int value) => (short)(value >> 16);
|
||||
|
||||
internal static int LoWord(int value) => (short)(value & 65535);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool ScreenToClient(IntPtr hWnd, ref InteropValues.POINT point);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern IntPtr MonitorFromWindow(IntPtr handle, int flags);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool ClientToScreen(IntPtr hWnd, ref InteropValues.POINT point);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool EnumThreadWindows(uint dwThreadId, InteropValues.EnumWindowsProc lpfn, IntPtr lParam);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool PostMessage(IntPtr hWnd, int nMsg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, int dwFlags);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool DeleteDC(IntPtr hdc);
|
||||
@@ -364,24 +315,6 @@ namespace HandyControl.Tools.Interop
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32, ExactSpelling = true, SetLastError = true)]
|
||||
internal static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32, CallingConvention = CallingConvention.StdCall, ExactSpelling = true)]
|
||||
internal static extern IntPtr CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nWidthEllipse, int nHeightEllipse);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32, CallingConvention = CallingConvention.StdCall, ExactSpelling = true)]
|
||||
internal static extern IntPtr CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32, CallingConvention = CallingConvention.StdCall, ExactSpelling = true)]
|
||||
internal static extern IntPtr CreateRectRgnIndirect(ref InteropValues.RECT lprc);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32, CallingConvention = CallingConvention.StdCall, ExactSpelling = true)]
|
||||
private static extern int CombineRgn(IntPtr hrngDest, IntPtr hrgnSrc1, IntPtr hrgnSrc2, int fnCombineMode);
|
||||
|
||||
internal static int CombineRgn(IntPtr hrnDest, IntPtr hrgnSrc1, IntPtr hrgnSrc2,
|
||||
InteropValues.CombineMode combineMode) => CombineRgn(hrnDest, hrgnSrc1, hrgnSrc2, (int) combineMode);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CallingConvention = CallingConvention.StdCall, ExactSpelling = true)]
|
||||
internal static extern int SetWindowRgn(IntPtr hWnd, IntPtr hRgn, [MarshalAs(UnmanagedType.Bool)] bool redraw);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
internal static extern IntPtr SendMessage(IntPtr hWnd, int nMsg, IntPtr wParam, IntPtr lParam);
|
||||
@@ -391,10 +324,6 @@ namespace HandyControl.Tools.Interop
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern IntPtr GetWindow(IntPtr hwnd, int nCmd);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool GetWindowInfo(IntPtr hwnd, ref InteropValues.WINDOWINFO pwi);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
@@ -427,10 +356,6 @@ namespace HandyControl.Tools.Interop
|
||||
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
|
||||
internal static int GetWindowLong(IntPtr hWnd, InteropValues.GWL nIndex) => GetWindowLong(hWnd, (int)nIndex);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool GetClientRect(IntPtr hwnd, out InteropValues.RECT lpRect);
|
||||
|
||||
internal static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
|
||||
{
|
||||
@@ -473,9 +398,6 @@ namespace HandyControl.Tools.Interop
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
internal static extern IntPtr CreateWindowEx(int dwExStyle, IntPtr classAtom, string lpWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32)]
|
||||
internal static extern IntPtr CreateSolidBrush(int colorref);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool DestroyWindow(IntPtr hwnd);
|
||||
@@ -490,11 +412,7 @@ namespace HandyControl.Tools.Interop
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern bool RedrawWindow(IntPtr hWnd, IntPtr lprcUpdate, IntPtr hrgnUpdate, InteropValues.RedrawWindowFlags flags);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool FillRect(IntPtr hDC, ref InteropValues.RECT rect, IntPtr hbrush);
|
||||
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip, InteropValues.EnumMonitorsDelegate lpfnEnum, IntPtr dwData);
|
||||
|
||||
@@ -26,12 +26,7 @@ namespace HandyControl.Tools.Interop
|
||||
|
||||
internal delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
|
||||
|
||||
internal delegate IntPtr SubclassProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, UIntPtr id, IntPtr refData);
|
||||
|
||||
internal delegate IntPtr WindowsHookProc(CbtHookAction code, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
internal const int
|
||||
WS_CHILD = 0x40000000,
|
||||
BITSPIXEL = 12,
|
||||
PLANES = 14,
|
||||
BI_RGB = 0,
|
||||
@@ -40,9 +35,6 @@ namespace HandyControl.Tools.Interop
|
||||
NIF_ICON = 0x00000002,
|
||||
NIF_TIP = 0x00000004,
|
||||
NIF_INFO = 0x00000010,
|
||||
NIN_BALLOONSHOW = WM_USER + 2,
|
||||
NIN_BALLOONHIDE = WM_USER + 3,
|
||||
NIN_BALLOONTIMEOUT = WM_USER + 4,
|
||||
NIM_ADD = 0x00000000,
|
||||
NIM_MODIFY = 0x00000001,
|
||||
NIM_DELETE = 0x00000002,
|
||||
@@ -50,22 +42,15 @@ namespace HandyControl.Tools.Interop
|
||||
NIIF_INFO = 0x00000001,
|
||||
NIIF_WARNING = 0x00000002,
|
||||
NIIF_ERROR = 0x00000003,
|
||||
NIIF_LARGE_ICON = 0x00000020,
|
||||
WM_KEYDOWN = 0x0100,
|
||||
WM_KEYUP = 0x0101,
|
||||
WM_SYSKEYDOWN = 0x0104,
|
||||
WM_SYSKEYUP = 0x0105,
|
||||
WM_SYSCOMMAND = 0x112,
|
||||
WM_MOUSEMOVE = 0x0200,
|
||||
WM_LBUTTONDOWN = 0x0201,
|
||||
WM_LBUTTONUP = 0x0202,
|
||||
WM_LBUTTONDBLCLK = 0x0203,
|
||||
WM_RBUTTONDOWN = 0x0204,
|
||||
WM_RBUTTONUP = 0x0205,
|
||||
WM_RBUTTONDBLCLK = 0x0206,
|
||||
WM_MBUTTONDOWN = 0x0207,
|
||||
WM_MBUTTONUP = 0x0208,
|
||||
WM_MBUTTONDBLCLK = 0x0209,
|
||||
WM_CLIPBOARDUPDATE = 0x031D,
|
||||
WM_USER = 0x0400,
|
||||
MF_BYPOSITION = 0x400,
|
||||
@@ -73,22 +58,10 @@ namespace HandyControl.Tools.Interop
|
||||
TB_GETBUTTON = WM_USER + 23,
|
||||
TB_BUTTONCOUNT = WM_USER + 24,
|
||||
TB_GETITEMRECT = WM_USER + 29,
|
||||
STANDARD_RIGHTS_REQUIRED = 0x000F0000,
|
||||
SYNCHRONIZE = 0x00100000,
|
||||
PROCESS_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF,
|
||||
MEM_COMMIT = 0x1000,
|
||||
MEM_RELEASE = 0x8000,
|
||||
PAGE_READWRITE = 0x04,
|
||||
TBSTATE_HIDDEN = 0x08,
|
||||
VERTRES = 10,
|
||||
HORZRES = 8,
|
||||
DESKTOPVERTRES = 117,
|
||||
DESKTOPHORZRES = 118,
|
||||
LOGPIXELSX = 88,
|
||||
LOGPIXELSY = 90,
|
||||
CXFRAME = 32,
|
||||
CXSIZEFRAME = CXFRAME,
|
||||
SW_HIDE = 0;
|
||||
LOGPIXELSY = 90;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
internal class NOTIFYICONDATA
|
||||
@@ -220,14 +193,6 @@ namespace HandyControl.Tools.Interop
|
||||
public int Right;
|
||||
public int Bottom;
|
||||
|
||||
public RECT(int left, int top, int right, int bottom)
|
||||
{
|
||||
Left = left;
|
||||
Top = top;
|
||||
Right = right;
|
||||
Bottom = bottom;
|
||||
}
|
||||
|
||||
public RECT(Rect rect)
|
||||
{
|
||||
Left = (int)rect.Left;
|
||||
@@ -250,16 +215,6 @@ namespace HandyControl.Tools.Interop
|
||||
get => Right - Left;
|
||||
set => Right = Left + value;
|
||||
}
|
||||
|
||||
public void Offset(int dx, int dy)
|
||||
{
|
||||
Left += dx;
|
||||
Right += dx;
|
||||
Top += dy;
|
||||
Bottom += dy;
|
||||
}
|
||||
|
||||
public Int32Rect ToInt32Rect() => new Int32Rect(Left, Top, Width, Height);
|
||||
}
|
||||
|
||||
internal struct BLENDFUNCTION
|
||||
@@ -269,11 +224,13 @@ namespace HandyControl.Tools.Interop
|
||||
public byte SourceConstantAlpha;
|
||||
public byte AlphaFormat;
|
||||
}
|
||||
|
||||
internal enum GWL
|
||||
{
|
||||
STYLE = -16,
|
||||
EXSTYLE = -20
|
||||
}
|
||||
|
||||
internal enum GWLP
|
||||
{
|
||||
WNDPROC = -4,
|
||||
@@ -282,26 +239,6 @@ namespace HandyControl.Tools.Interop
|
||||
USERDATA = -21,
|
||||
ID = -12
|
||||
}
|
||||
internal enum CombineMode
|
||||
{
|
||||
RGN_AND = 1,
|
||||
RGN_OR,
|
||||
RGN_XOR,
|
||||
RGN_DIFF,
|
||||
RGN_COPY,
|
||||
RGN_MIN = 1,
|
||||
RGN_MAX = 5
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class BITMAPFILEHEADER
|
||||
{
|
||||
public ushort bfType;
|
||||
public uint bfSize;
|
||||
public ushort bfReserved1;
|
||||
public ushort bfReserved2;
|
||||
public uint bfOffBits;
|
||||
}
|
||||
|
||||
internal struct BITMAPINFOHEADER
|
||||
{
|
||||
@@ -318,23 +255,6 @@ namespace HandyControl.Tools.Interop
|
||||
internal uint biClrImportant;
|
||||
}
|
||||
|
||||
internal struct PictDescBitmap
|
||||
{
|
||||
internal int cbSizeOfStruct;
|
||||
internal int pictureType;
|
||||
internal IntPtr hBitmap;
|
||||
internal IntPtr hPalette;
|
||||
internal int unused;
|
||||
internal static PictDescBitmap Default =>
|
||||
new PictDescBitmap
|
||||
{
|
||||
cbSizeOfStruct = 20,
|
||||
pictureType = 1,
|
||||
hBitmap = IntPtr.Zero,
|
||||
hPalette = IntPtr.Zero
|
||||
};
|
||||
}
|
||||
|
||||
[Flags]
|
||||
internal enum RedrawWindowFlags : uint
|
||||
{
|
||||
@@ -352,20 +272,6 @@ namespace HandyControl.Tools.Interop
|
||||
NoFrame = 2048u
|
||||
}
|
||||
|
||||
internal enum CbtHookAction
|
||||
{
|
||||
HCBT_MOVESIZE,
|
||||
HCBT_MINMAX,
|
||||
HCBT_QS,
|
||||
HCBT_CREATEWND,
|
||||
HCBT_DESTROYWND,
|
||||
HCBT_ACTIVATE,
|
||||
HCBT_CLICKSKIPPED,
|
||||
HCBT_KEYSKIPPED,
|
||||
HCBT_SYSCOMMAND,
|
||||
HCBT_SETFOCUS
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class WINDOWPOS
|
||||
{
|
||||
@@ -389,20 +295,6 @@ namespace HandyControl.Tools.Interop
|
||||
public RECT rcNormalPosition;
|
||||
}
|
||||
|
||||
internal struct WINDOWINFO
|
||||
{
|
||||
public int cbSize;
|
||||
public RECT rcWindow;
|
||||
public RECT rcClient;
|
||||
public int dwStyle;
|
||||
public int dwExStyle;
|
||||
public uint dwWindowStatus;
|
||||
public uint cxWindowBorders;
|
||||
public uint cyWindowBorders;
|
||||
public ushort atomWindowType;
|
||||
public ushort wCreatorVersion;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
internal struct SIZE
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user