add function codes
This commit is contained in:
1 parent
cae862d6b0
commit
c1d6e901b2
31 files changed
+2428
-169
No files matched your search
@@ -10,83 +10,87 @@ namespace HandyControl.Tools.Interop
|
||||
{
|
||||
internal class InteropMethods
|
||||
{
|
||||
private static int vsmNotifyOwnerActivate;
|
||||
|
||||
public static readonly IntPtr HRGN_NONE = new IntPtr(-1);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
public static extern int RegisterWindowMessage(string msg);
|
||||
internal static extern int RegisterWindowMessage(string msg);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, ref InteropValues.RECT lpPoints, uint cPoints);
|
||||
internal static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, ref InteropValues.RECT lpPoints, uint cPoints);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.TBBUTTON lpBuffer,
|
||||
internal static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.TBBUTTON lpBuffer,
|
||||
int dwSize, out int lpNumberOfBytesRead);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true)]
|
||||
public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.RECT lpBuffer,
|
||||
internal static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.RECT lpBuffer,
|
||||
int dwSize, out int lpNumberOfBytesRead);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true)]
|
||||
public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.TRAYDATA lpBuffer,
|
||||
internal static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.TRAYDATA lpBuffer,
|
||||
int dwSize, out int lpNumberOfBytesRead);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
|
||||
public static extern uint SendMessage(IntPtr hWnd, uint Msg, uint wParam, IntPtr lParam);
|
||||
internal static extern uint SendMessage(IntPtr hWnd, uint Msg, uint wParam, IntPtr lParam);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
|
||||
internal static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr OpenProcess(InteropValues.ProcessAccess dwDesiredAccess,
|
||||
internal static extern IntPtr OpenProcess(InteropValues.ProcessAccess dwDesiredAccess,
|
||||
[MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, uint dwProcessId);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, int dwSize,
|
||||
internal static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, int dwSize,
|
||||
InteropValues.AllocationType flAllocationType, InteropValues.MemoryProtection flProtect);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern int CloseHandle(IntPtr hObject);
|
||||
internal static extern int CloseHandle(IntPtr hObject);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress, int dwSize, InteropValues.FreeType dwFreeType);
|
||||
internal static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress, int dwSize, InteropValues.FreeType dwFreeType);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
internal static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass,
|
||||
internal static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass,
|
||||
string lpszWindow);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
public static extern int GetWindowRect(IntPtr hwnd, out InteropValues.RECT lpRect);
|
||||
internal static extern int GetWindowRect(IntPtr hwnd, out InteropValues.RECT lpRect);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
|
||||
public static extern bool GetCursorPos(out InteropValues.POINT pt);
|
||||
internal static extern bool GetCursorPos(out InteropValues.POINT pt);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
public static extern IntPtr GetDesktopWindow();
|
||||
internal static extern IntPtr GetDesktopWindow();
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool AddClipboardFormatListener(IntPtr hwnd);
|
||||
internal static extern bool AddClipboardFormatListener(IntPtr hwnd);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool RemoveClipboardFormatListener(IntPtr hwnd);
|
||||
internal static extern bool RemoveClipboardFormatListener(IntPtr hwnd);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
public static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
|
||||
internal static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
public static extern bool InsertMenu(IntPtr hMenu, int wPosition, int wFlags, int wIDNewItem, string lpNewItem);
|
||||
internal static extern bool InsertMenu(IntPtr hMenu, int wPosition, int wFlags, int wIDNewItem, string lpNewItem);
|
||||
|
||||
[SecurityCritical]
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
[DllImport(InteropValues.ExternDll.User32, SetLastError = true, ExactSpelling = true, EntryPoint = nameof(GetDC),
|
||||
CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr IntGetDC(HandleRef hWnd);
|
||||
internal static extern IntPtr IntGetDC(HandleRef hWnd);
|
||||
|
||||
[SecurityCritical]
|
||||
public static IntPtr GetDC(HandleRef hWnd)
|
||||
internal static IntPtr GetDC(HandleRef hWnd)
|
||||
{
|
||||
var hDc = IntGetDC(hWnd);
|
||||
if (hDc == IntPtr.Zero) throw new Win32Exception();
|
||||
@@ -97,10 +101,10 @@ namespace HandyControl.Tools.Interop
|
||||
[SecurityCritical]
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
[DllImport(InteropValues.ExternDll.User32, ExactSpelling = true, EntryPoint = nameof(ReleaseDC), CharSet = CharSet.Auto)]
|
||||
public static extern int IntReleaseDC(HandleRef hWnd, HandleRef hDC);
|
||||
internal static extern int IntReleaseDC(HandleRef hWnd, HandleRef hDC);
|
||||
|
||||
[SecurityCritical]
|
||||
public static int ReleaseDC(HandleRef hWnd, HandleRef hDC)
|
||||
internal static int ReleaseDC(HandleRef hWnd, HandleRef hDC)
|
||||
{
|
||||
HandleCollector.Remove((IntPtr) hDC, CommonHandles.HDC);
|
||||
return IntReleaseDC(hWnd, hDC);
|
||||
@@ -109,12 +113,12 @@ namespace HandyControl.Tools.Interop
|
||||
[SecurityCritical]
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
[DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
|
||||
public static extern int GetDeviceCaps(HandleRef hDC, int nIndex);
|
||||
internal static extern int GetDeviceCaps(HandleRef hDC, int nIndex);
|
||||
|
||||
[SecurityCritical]
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
public static extern int GetSystemMetrics(InteropValues.SM nIndex);
|
||||
internal static extern int GetSystemMetrics(InteropValues.SM nIndex);
|
||||
|
||||
[SecurityCritical]
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
@@ -122,7 +126,7 @@ namespace HandyControl.Tools.Interop
|
||||
private static extern bool IntDestroyIcon(IntPtr hIcon);
|
||||
|
||||
[SecurityCritical]
|
||||
public static bool DestroyIcon(IntPtr hIcon)
|
||||
internal static bool DestroyIcon(IntPtr hIcon)
|
||||
{
|
||||
var result = IntDestroyIcon(hIcon);
|
||||
return result;
|
||||
@@ -134,14 +138,14 @@ namespace HandyControl.Tools.Interop
|
||||
private static extern bool IntDeleteObject(IntPtr hObject);
|
||||
|
||||
[SecurityCritical]
|
||||
public static bool DeleteObject(IntPtr hObject)
|
||||
internal static bool DeleteObject(IntPtr hObject)
|
||||
{
|
||||
var result = IntDeleteObject(hObject);
|
||||
return result;
|
||||
}
|
||||
|
||||
[SecurityCritical]
|
||||
public static BitmapHandle CreateDIBSection(HandleRef hdc, ref InteropValues.BITMAPINFO bitmapInfo, int iUsage,
|
||||
internal static BitmapHandle CreateDIBSection(HandleRef hdc, ref InteropValues.BITMAPINFO bitmapInfo, int iUsage,
|
||||
ref IntPtr ppvBits, SafeFileMappingHandle hSection, int dwOffset)
|
||||
{
|
||||
if (hSection == null) hSection = new SafeFileMappingHandle(IntPtr.Zero);
|
||||
@@ -151,7 +155,7 @@ namespace HandyControl.Tools.Interop
|
||||
}
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Kernel32, EntryPoint = "CloseHandle", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern bool IntCloseHandle(HandleRef handle);
|
||||
internal static extern bool IntCloseHandle(HandleRef handle);
|
||||
|
||||
[SecurityCritical]
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
@@ -168,7 +172,7 @@ namespace HandyControl.Tools.Interop
|
||||
InteropValues.ICONINFO iconInfo);
|
||||
|
||||
[SecurityCritical]
|
||||
public static IconHandle CreateIconIndirect([In] [MarshalAs(UnmanagedType.LPStruct)]
|
||||
internal static IconHandle CreateIconIndirect([In] [MarshalAs(UnmanagedType.LPStruct)]
|
||||
InteropValues.ICONINFO iconInfo)
|
||||
{
|
||||
var hIcon = PrivateCreateIconIndirect(iconInfo);
|
||||
@@ -221,12 +225,12 @@ namespace HandyControl.Tools.Interop
|
||||
out IconHandle phiconSmall, int nIcons);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Shell32, CharSet = CharSet.Auto)]
|
||||
public static extern int Shell_NotifyIcon(int message, InteropValues.NOTIFYICONDATA pnid);
|
||||
internal static extern int Shell_NotifyIcon(int message, InteropValues.NOTIFYICONDATA pnid);
|
||||
|
||||
[SecurityCritical]
|
||||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
[DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CreateWindowExW")]
|
||||
public static extern IntPtr CreateWindowEx(
|
||||
internal static extern IntPtr CreateWindowEx(
|
||||
int dwExStyle,
|
||||
[MarshalAs(UnmanagedType.LPWStr)] string lpClassName,
|
||||
[MarshalAs(UnmanagedType.LPWStr)] string lpWindowName,
|
||||
@@ -243,39 +247,273 @@ namespace HandyControl.Tools.Interop
|
||||
[SecurityCritical]
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
|
||||
public static extern short RegisterClass(InteropValues.WNDCLASS wc);
|
||||
internal static extern short RegisterClass(InteropValues.WNDCLASS wc);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr DefWindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||
internal static extern IntPtr DefWindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
|
||||
public static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||
internal static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
|
||||
internal static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Kernel32, CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern IntPtr GetModuleHandle(string lpModuleName);
|
||||
internal static extern IntPtr GetModuleHandle(string lpModuleName);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern bool UnhookWindowsHookEx(IntPtr hhk);
|
||||
internal static extern bool UnhookWindowsHookEx(IntPtr hhk);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern IntPtr SetWindowsHookEx(int idHook, InteropValues.HookProc lpfn, IntPtr hMod, uint dwThreadId);
|
||||
internal static extern IntPtr SetWindowsHookEx(int idHook, InteropValues.HookProc lpfn, IntPtr hMod, uint dwThreadId);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||
public static extern IntPtr GetWindowDC(IntPtr window);
|
||||
internal static extern IntPtr GetWindowDC(IntPtr window);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true)]
|
||||
public static extern uint GetPixel(IntPtr dc, int x, int y);
|
||||
internal static extern uint GetPixel(IntPtr dc, int x, int y);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||
public static extern int ReleaseDC(IntPtr window, IntPtr dc);
|
||||
internal static extern int ReleaseDC(IntPtr window, IntPtr dc);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
|
||||
public static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
|
||||
internal static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr GetDC(IntPtr ptr);
|
||||
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);
|
||||
|
||||
internal static InteropValues.WINDOWPLACEMENT GetWindowPlacement(IntPtr hwnd)
|
||||
{
|
||||
InteropValues.WINDOWPLACEMENT wINDOWPLACEMENT = new InteropValues.WINDOWPLACEMENT();
|
||||
if (GetWindowPlacement(hwnd, wINDOWPLACEMENT))
|
||||
{
|
||||
return wINDOWPLACEMENT;
|
||||
}
|
||||
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);
|
||||
|
||||
internal static int GetYLParam(int lParam) => HiWord(lParam);
|
||||
|
||||
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);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true)]
|
||||
internal static extern IntPtr CreateCompatibleDC(IntPtr hdc);
|
||||
|
||||
[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);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern IntPtr MonitorFromPoint(InteropValues.POINT pt, int flags);
|
||||
|
||||
[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)]
|
||||
internal static extern bool IsWindowVisible(IntPtr hwnd);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool IsIconic(IntPtr hwnd);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool IsZoomed(IntPtr hwnd);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, int flags);
|
||||
|
||||
internal static System.Windows.Point GetCursorPos()
|
||||
{
|
||||
var result = default(System.Windows.Point);
|
||||
if (GetCursorPos(out var point))
|
||||
{
|
||||
result.X = point.X;
|
||||
result.Y = point.Y;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
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)
|
||||
{
|
||||
if (IntPtr.Size == 4)
|
||||
{
|
||||
return SetWindowLongPtr32(hWnd, nIndex, dwNewLong);
|
||||
}
|
||||
return SetWindowLongPtr64(hWnd, nIndex, dwNewLong);
|
||||
}
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, EntryPoint = "SetWindowLong")]
|
||||
internal static extern IntPtr SetWindowLongPtr32(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, EntryPoint = "SetWindowLongPtr")]
|
||||
internal static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode)]
|
||||
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode)]
|
||||
private static extern IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
|
||||
|
||||
internal static IntPtr SetWindowLongPtr(IntPtr hWnd, InteropValues.GWLP nIndex, IntPtr dwNewLong)
|
||||
{
|
||||
if (IntPtr.Size == 8)
|
||||
{
|
||||
return SetWindowLongPtr(hWnd, (int)nIndex, dwNewLong);
|
||||
}
|
||||
return new IntPtr(SetWindowLong(hWnd, (int)nIndex, dwNewLong.ToInt32()));
|
||||
}
|
||||
|
||||
internal static int SetWindowLong(IntPtr hWnd, InteropValues.GWL nIndex, int dwNewLong) => SetWindowLong(hWnd, (int)nIndex, dwNewLong);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode)]
|
||||
internal static extern ushort RegisterClass(ref InteropValues.WNDCLASS lpWndClass);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Kernel32)]
|
||||
internal static extern uint GetCurrentThreadId();
|
||||
|
||||
[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);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool UnregisterClass(IntPtr classAtom, IntPtr hInstance);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDest, ref InteropValues.POINT pptDest, ref InteropValues.SIZE psize, IntPtr hdcSrc, ref InteropValues.POINT pptSrc, uint crKey, [In] ref InteropValues.BLENDFUNCTION pblend, uint dwFlags);
|
||||
|
||||
[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);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool IntersectRect(out InteropValues.RECT lprcDst, [In] ref InteropValues.RECT lprcSrc1, [In] ref InteropValues.RECT lprcSrc2);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool GetMonitorInfo(IntPtr hMonitor, ref InteropValues.MONITORINFO monitorInfo);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true)]
|
||||
internal static extern IntPtr CreateDIBSection(IntPtr hdc, ref InteropValues.BITMAPINFO pbmi, uint iUsage, out IntPtr ppvBits, IntPtr hSection, uint dwOffset);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.MsImg)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool AlphaBlend(IntPtr hdcDest, int xoriginDest, int yoriginDest, int wDest, int hDest, IntPtr hdcSrc, int xoriginSrc, int yoriginSrc, int wSrc, int hSrc, InteropValues.BLENDFUNCTION pfn);
|
||||
|
||||
internal static int GET_SC_WPARAM(IntPtr wParam) => (int)wParam & 65520;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,36 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Tools.Interop
|
||||
{
|
||||
public class InteropValues
|
||||
internal class InteropValues
|
||||
{
|
||||
#region public
|
||||
internal static class ExternDll
|
||||
{
|
||||
public const string
|
||||
User32 = "user32.dll",
|
||||
Gdi32 = "gdi32.dll",
|
||||
Kernel32 = "kernel32.dll",
|
||||
Shell32 = "shell32.dll",
|
||||
MsImg = "msimg32.dll";
|
||||
}
|
||||
|
||||
public delegate IntPtr HookProc(int code, IntPtr wParam, IntPtr lParam);
|
||||
internal delegate IntPtr HookProc(int code, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
public delegate IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||
internal delegate IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
public const int
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal delegate bool EnumMonitorsDelegate(IntPtr hMonitor, IntPtr hdcMonitor, ref RECT lprcMonitor, IntPtr dwData);
|
||||
|
||||
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,
|
||||
@@ -73,7 +91,7 @@ namespace HandyControl.Tools.Interop
|
||||
SW_HIDE = 0;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
public class NOTIFYICONDATA
|
||||
internal class NOTIFYICONDATA
|
||||
{
|
||||
public int cbSize = Marshal.SizeOf(typeof(NOTIFYICONDATA));
|
||||
public IntPtr hWnd;
|
||||
@@ -93,40 +111,8 @@ namespace HandyControl.Tools.Interop
|
||||
public int dwInfoFlags;
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum ProcessAccess
|
||||
{
|
||||
AllAccess = CreateThread | DuplicateHandle | QueryInformation | SetInformation | Terminate | VMOperation | VMRead | VMWrite | Synchronize,
|
||||
CreateThread = 0x2,
|
||||
DuplicateHandle = 0x40,
|
||||
QueryInformation = 0x400,
|
||||
SetInformation = 0x200,
|
||||
Terminate = 0x1,
|
||||
VMOperation = 0x8,
|
||||
VMRead = 0x10,
|
||||
VMWrite = 0x20,
|
||||
Synchronize = 0x100000
|
||||
}
|
||||
|
||||
[Serializable, StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
public struct RECT
|
||||
{
|
||||
public int Left;
|
||||
public int Top;
|
||||
public int Right;
|
||||
public int Bottom;
|
||||
|
||||
public RECT(int left, int top, int right, int bottom)
|
||||
{
|
||||
Left = left;
|
||||
Top = top;
|
||||
Right = right;
|
||||
Bottom = bottom;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct TBBUTTON
|
||||
internal struct TBBUTTON
|
||||
{
|
||||
public int iBitmap;
|
||||
public int idCommand;
|
||||
@@ -136,7 +122,7 @@ namespace HandyControl.Tools.Interop
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum AllocationType
|
||||
internal enum AllocationType
|
||||
{
|
||||
Commit = 0x1000,
|
||||
Reserve = 0x2000,
|
||||
@@ -150,7 +136,7 @@ namespace HandyControl.Tools.Interop
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum MemoryProtection
|
||||
internal enum MemoryProtection
|
||||
{
|
||||
Execute = 0x10,
|
||||
ExecuteRead = 0x20,
|
||||
@@ -166,7 +152,7 @@ namespace HandyControl.Tools.Interop
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct TRAYDATA
|
||||
internal struct TRAYDATA
|
||||
{
|
||||
public IntPtr hwnd;
|
||||
public uint uID;
|
||||
@@ -177,14 +163,14 @@ namespace HandyControl.Tools.Interop
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum FreeType
|
||||
internal enum FreeType
|
||||
{
|
||||
Decommit = 0x4000,
|
||||
Release = 0x8000,
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct POINT
|
||||
internal struct POINT
|
||||
{
|
||||
public int X;
|
||||
public int Y;
|
||||
@@ -196,14 +182,14 @@ namespace HandyControl.Tools.Interop
|
||||
}
|
||||
}
|
||||
|
||||
public enum HookType
|
||||
internal enum HookType
|
||||
{
|
||||
WH_KEYBOARD_LL = 13,
|
||||
WH_MOUSE_LL = 14
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct MOUSEHOOKSTRUCT
|
||||
internal struct MOUSEHOOKSTRUCT
|
||||
{
|
||||
public POINT pt;
|
||||
public IntPtr hwnd;
|
||||
@@ -211,17 +197,227 @@ namespace HandyControl.Tools.Interop
|
||||
public IntPtr dwExtraInfo;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region internal
|
||||
|
||||
internal static class ExternDll
|
||||
[Flags]
|
||||
internal enum ProcessAccess
|
||||
{
|
||||
public const string
|
||||
User32 = "user32.dll",
|
||||
Gdi32 = "gdi32.dll",
|
||||
Kernel32 = "kernel32.dll",
|
||||
Shell32 = "shell32.dll";
|
||||
AllAccess = CreateThread | DuplicateHandle | QueryInformation | SetInformation | Terminate | VMOperation | VMRead | VMWrite | Synchronize,
|
||||
CreateThread = 0x2,
|
||||
DuplicateHandle = 0x40,
|
||||
QueryInformation = 0x400,
|
||||
SetInformation = 0x200,
|
||||
Terminate = 0x1,
|
||||
VMOperation = 0x8,
|
||||
VMRead = 0x10,
|
||||
VMWrite = 0x20,
|
||||
Synchronize = 0x100000
|
||||
}
|
||||
|
||||
[Serializable, StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
internal struct RECT
|
||||
{
|
||||
public int Left;
|
||||
public int Top;
|
||||
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;
|
||||
Top = (int)rect.Top;
|
||||
Right = (int)rect.Right;
|
||||
Bottom = (int)rect.Bottom;
|
||||
}
|
||||
|
||||
public Point Position => new Point(Left, Top);
|
||||
public Size Size => new Size(Width, Height);
|
||||
|
||||
public int Height
|
||||
{
|
||||
get => Bottom - Top;
|
||||
set => Bottom = Top + value;
|
||||
}
|
||||
|
||||
public int Width
|
||||
{
|
||||
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
|
||||
{
|
||||
public byte BlendOp;
|
||||
public byte BlendFlags;
|
||||
public byte SourceConstantAlpha;
|
||||
public byte AlphaFormat;
|
||||
}
|
||||
internal enum GWL
|
||||
{
|
||||
STYLE = -16,
|
||||
EXSTYLE = -20
|
||||
}
|
||||
internal enum GWLP
|
||||
{
|
||||
WNDPROC = -4,
|
||||
HINSTANCE = -6,
|
||||
HWNDPARENT = -8,
|
||||
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
|
||||
{
|
||||
internal uint biSize;
|
||||
internal int biWidth;
|
||||
internal int biHeight;
|
||||
internal ushort biPlanes;
|
||||
internal ushort biBitCount;
|
||||
internal uint biCompression;
|
||||
internal uint biSizeImage;
|
||||
internal int biXPelsPerMeter;
|
||||
internal int biYPelsPerMeter;
|
||||
internal uint biClrUsed;
|
||||
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
|
||||
{
|
||||
Invalidate = 1u,
|
||||
InternalPaint = 2u,
|
||||
Erase = 4u,
|
||||
Validate = 8u,
|
||||
NoInternalPaint = 16u,
|
||||
NoErase = 32u,
|
||||
NoChildren = 64u,
|
||||
AllChildren = 128u,
|
||||
UpdateNow = 256u,
|
||||
EraseNow = 512u,
|
||||
Frame = 1024u,
|
||||
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
|
||||
{
|
||||
public IntPtr hwnd;
|
||||
public IntPtr hwndInsertAfter;
|
||||
public int x;
|
||||
public int y;
|
||||
public int cx;
|
||||
public int cy;
|
||||
public uint flags;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class WINDOWPLACEMENT
|
||||
{
|
||||
public int length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
|
||||
public int flags;
|
||||
public int showCmd;
|
||||
public POINT ptMinPosition;
|
||||
public POINT ptMaxPosition;
|
||||
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
|
||||
{
|
||||
[ComAliasName("Microsoft.VisualStudio.OLE.Interop.LONG")]
|
||||
public int cx;
|
||||
[ComAliasName("Microsoft.VisualStudio.OLE.Interop.LONG")]
|
||||
public int cy;
|
||||
}
|
||||
|
||||
internal struct MONITORINFO
|
||||
{
|
||||
public uint cbSize;
|
||||
public RECT rcMonitor;
|
||||
public RECT rcWork;
|
||||
public uint dwFlags;
|
||||
}
|
||||
|
||||
internal enum SM
|
||||
@@ -455,59 +651,61 @@ namespace HandyControl.Tools.Interop
|
||||
internal const int FALSE = 0;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
internal class WNDCLASS
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
internal struct WNDCLASS
|
||||
{
|
||||
public int style;
|
||||
public WndProc lpfnWndProc;
|
||||
public uint style;
|
||||
public Delegate lpfnWndProc;
|
||||
public int cbClsExtra;
|
||||
public int cbWndExtra;
|
||||
public IntPtr hInstance;
|
||||
public IntPtr hIcon;
|
||||
public IntPtr hCursor;
|
||||
public IntPtr hbrBackground;
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
public string lpszMenuName;
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
public string lpszClassName;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 2)]
|
||||
internal struct BITMAPINFO
|
||||
{
|
||||
public int bmiHeader_biSize;
|
||||
public int biSize;
|
||||
|
||||
public int bmiHeader_biWidth;
|
||||
public int biWidth;
|
||||
|
||||
public int bmiHeader_biHeight;
|
||||
public int biHeight;
|
||||
|
||||
public short bmiHeader_biPlanes;
|
||||
public short biPlanes;
|
||||
|
||||
public short bmiHeader_biBitCount;
|
||||
public short biBitCount;
|
||||
|
||||
public int bmiHeader_biCompression;
|
||||
public int biCompression;
|
||||
|
||||
public int bmiHeader_biSizeImage;
|
||||
public int biSizeImage;
|
||||
|
||||
public int bmiHeader_biXPelsPerMeter;
|
||||
public int biXPelsPerMeter;
|
||||
|
||||
public int bmiHeader_biYPelsPerMeter;
|
||||
public int biYPelsPerMeter;
|
||||
|
||||
public int bmiHeader_biClrUsed;
|
||||
public int biClrUsed;
|
||||
|
||||
public int bmiHeader_biClrImportant;
|
||||
public int biClrImportant;
|
||||
|
||||
public BITMAPINFO(int width, int height, short bpp)
|
||||
{
|
||||
bmiHeader_biSize = SizeOf();
|
||||
bmiHeader_biWidth = width;
|
||||
bmiHeader_biHeight = height;
|
||||
bmiHeader_biPlanes = 1;
|
||||
bmiHeader_biBitCount = bpp;
|
||||
bmiHeader_biCompression = 0;
|
||||
bmiHeader_biSizeImage = 0;
|
||||
bmiHeader_biXPelsPerMeter = 0;
|
||||
bmiHeader_biYPelsPerMeter = 0;
|
||||
bmiHeader_biClrUsed = 0;
|
||||
bmiHeader_biClrImportant = 0;
|
||||
biSize = SizeOf();
|
||||
biWidth = width;
|
||||
biHeight = height;
|
||||
biPlanes = 1;
|
||||
biBitCount = bpp;
|
||||
biCompression = 0;
|
||||
biSizeImage = 0;
|
||||
biXPelsPerMeter = 0;
|
||||
biYPelsPerMeter = 0;
|
||||
biClrUsed = 0;
|
||||
biClrImportant = 0;
|
||||
}
|
||||
|
||||
[SecuritySafeCritical]
|
||||
@@ -526,7 +724,5 @@ namespace HandyControl.Tools.Interop
|
||||
public BitmapHandle hbmMask = null;
|
||||
public BitmapHandle hbmColor = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user