csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
4.0 KiB
118 lines
4.0 KiB
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
|
|
namespace IntegrationTestApp.Embedding;
|
|
|
|
internal class WinApi
|
|
{
|
|
public const int GWL_WNDPROC = -4;
|
|
public const uint TME_HOVER = 1;
|
|
public const uint TME_LEAVE = 2;
|
|
public const uint WM_CONTEXTMENU = 0x007B;
|
|
public const uint WM_MOUSELEAVE = 0x02A3;
|
|
public const uint WM_MOUSEHOVER = 0x02A1;
|
|
public const uint WM_MOUSEMOVE = 0x0200;
|
|
|
|
public delegate IntPtr WndProcDelegate(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
|
|
|
|
[Flags]
|
|
public enum WindowStyles : uint
|
|
{
|
|
WS_BORDER = 0x800000,
|
|
WS_CAPTION = 0xc00000,
|
|
WS_CHILD = 0x40000000,
|
|
WS_CLIPCHILDREN = 0x2000000,
|
|
WS_CLIPSIBLINGS = 0x4000000,
|
|
WS_DISABLED = 0x8000000,
|
|
WS_DLGFRAME = 0x400000,
|
|
WS_GROUP = 0x20000,
|
|
WS_HSCROLL = 0x100000,
|
|
WS_MAXIMIZE = 0x1000000,
|
|
WS_MAXIMIZEBOX = 0x10000,
|
|
WS_MINIMIZE = 0x20000000,
|
|
WS_MINIMIZEBOX = 0x20000,
|
|
WS_OVERLAPPED = 0x0,
|
|
WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
|
|
WS_POPUP = 0x80000000u,
|
|
WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU,
|
|
WS_SYSMENU = 0x80000,
|
|
WS_TABSTOP = 0x10000,
|
|
WS_THICKFRAME = 0x40000,
|
|
WS_VISIBLE = 0x10000000,
|
|
WS_VSCROLL = 0x200000,
|
|
WS_EX_DLGMODALFRAME = 0x00000001,
|
|
WS_EX_NOPARENTNOTIFY = 0x00000004,
|
|
WS_EX_NOREDIRECTIONBITMAP = 0x00200000,
|
|
WS_EX_TOPMOST = 0x00000008,
|
|
WS_EX_ACCEPTFILES = 0x00000010,
|
|
WS_EX_TRANSPARENT = 0x00000020,
|
|
WS_EX_MDICHILD = 0x00000040,
|
|
WS_EX_TOOLWINDOW = 0x00000080,
|
|
WS_EX_WINDOWEDGE = 0x00000100,
|
|
WS_EX_CLIENTEDGE = 0x00000200,
|
|
WS_EX_CONTEXTHELP = 0x00000400,
|
|
WS_EX_RIGHT = 0x00001000,
|
|
WS_EX_LEFT = 0x00000000,
|
|
WS_EX_RTLREADING = 0x00002000,
|
|
WS_EX_LTRREADING = 0x00000000,
|
|
WS_EX_LEFTSCROLLBAR = 0x00004000,
|
|
WS_EX_RIGHTSCROLLBAR = 0x00000000,
|
|
WS_EX_CONTROLPARENT = 0x00010000,
|
|
WS_EX_STATICEDGE = 0x00020000,
|
|
WS_EX_APPWINDOW = 0x00040000,
|
|
WS_EX_OVERLAPPEDWINDOW = WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
|
|
WS_EX_PALETTEWINDOW = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST,
|
|
WS_EX_LAYERED = 0x00080000,
|
|
WS_EX_NOINHERITLAYOUT = 0x00100000,
|
|
WS_EX_LAYOUTRTL = 0x00400000,
|
|
WS_EX_COMPOSITED = 0x02000000,
|
|
WS_EX_NOACTIVATE = 0x08000000
|
|
}
|
|
|
|
[DllImport("user32.dll", SetLastError = true)]
|
|
public static extern IntPtr CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
|
|
|
|
[DllImport("user32.dll", SetLastError = true)]
|
|
public static extern bool DestroyWindow(IntPtr hwnd);
|
|
|
|
[DllImport("kernel32.dll")]
|
|
public static extern IntPtr GetModuleHandle(string? lpModuleName);
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
|
|
|
|
|
|
[DllImport("user32.dll", SetLastError = true)]
|
|
public static extern IntPtr CreateWindowEx(
|
|
int dwExStyle,
|
|
string lpClassName,
|
|
string lpWindowName,
|
|
uint dwStyle,
|
|
int x,
|
|
int y,
|
|
int nWidth,
|
|
int nHeight,
|
|
IntPtr hWndParent,
|
|
IntPtr hMenu,
|
|
IntPtr hInstance,
|
|
IntPtr lpParam);
|
|
|
|
[DllImport("user32.dll", SetLastError = true)]
|
|
public static extern IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
|
|
|
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
|
public static extern bool SetWindowText(IntPtr hwnd, String lpString);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern bool TrackMouseEvent(ref TRACKMOUSEEVENT lpEventTrack);
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct TRACKMOUSEEVENT
|
|
{
|
|
public int cbSize;
|
|
public uint dwFlags;
|
|
public IntPtr hwndTrack;
|
|
public uint dwHoverTime;
|
|
}
|
|
}
|
|
|