mirror of
https://github.com/ckaczor/Common.Native.git
synced 2026-02-12 02:58:32 -05:00
More Win32 support
This commit is contained in:
29
Constants.cs
29
Constants.cs
@@ -138,13 +138,40 @@ namespace Common.Native
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum ExtendedWindowStyles
|
public enum WindowStyles : uint
|
||||||
{
|
{
|
||||||
|
Overlapped = 0x00000000,
|
||||||
|
Caption = 0x00C00000,
|
||||||
|
SystemMenu = 0x00080000,
|
||||||
|
ThickFrame = 0x00040000,
|
||||||
|
MinimizeBox = 0x00020000,
|
||||||
|
MaximizeBox = 0x00010000,
|
||||||
|
Visible = 0x10000000,
|
||||||
|
Child = 0x40000000,
|
||||||
|
Popup = 0x80000000,
|
||||||
|
OverlappedWindow = Overlapped | Caption | SystemMenu | ThickFrame | MinimizeBox | MaximizeBox
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum ExtendedWindowStyles : long
|
||||||
|
{
|
||||||
|
DialogModalFrame = 0x00000001,
|
||||||
ToolWindow = 0x00000080,
|
ToolWindow = 0x00000080,
|
||||||
|
AppWindow = 0x00040000,
|
||||||
|
WindowEdge = 0x00000100,
|
||||||
|
ClientEdge = 0x00000200,
|
||||||
|
OverlappedWindow = WindowEdge | ClientEdge
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum GetWindowFields
|
||||||
|
{
|
||||||
|
Owner = 4
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum GetWindowLongFields
|
public enum GetWindowLongFields
|
||||||
{
|
{
|
||||||
|
Parent = -8,
|
||||||
|
Style = -16,
|
||||||
ExStyle = -20,
|
ExStyle = -20,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
22
Functions.cs
22
Functions.cs
@@ -139,6 +139,9 @@ namespace Common.Native
|
|||||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
|
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||||
public static extern IntPtr SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
|
public static extern IntPtr SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
@@ -148,8 +151,11 @@ namespace Common.Native
|
|||||||
[DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
|
[DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
|
||||||
public static extern IntPtr GetParent(IntPtr hWnd);
|
public static extern IntPtr GetParent(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
|
||||||
|
public static extern IntPtr GetWindow(IntPtr hwnd, int wFlag);
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
public static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex);
|
public static extern long GetWindowLong(IntPtr hWnd, Constants.GetWindowLongFields nIndex);
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
||||||
@@ -163,6 +169,10 @@ namespace Common.Native
|
|||||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
public static extern uint RegisterWindowMessage(string lpString);
|
public static extern uint RegisterWindowMessage(string lpString);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool IsWindowVisible(IntPtr hWnd);
|
||||||
|
|
||||||
public static IntPtr SetWindowLongPtrSmart(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
|
public static IntPtr SetWindowLongPtrSmart(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
|
||||||
{
|
{
|
||||||
if (IntPtr.Size == 8)
|
if (IntPtr.Size == 8)
|
||||||
@@ -184,6 +194,16 @@ namespace Common.Native
|
|||||||
|
|
||||||
return new IntPtr(GetClassLongPtr32(hWnd, nIndex));
|
return new IntPtr(GetClassLongPtr32(hWnd, nIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool HasStyle(long windowStyle, Constants.WindowStyles checkStyle)
|
||||||
|
{
|
||||||
|
return ((windowStyle & (long) checkStyle) == (long) checkStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HasExtendedStyle(long windowStyle, Constants.ExtendedWindowStyles checkStyle)
|
||||||
|
{
|
||||||
|
return ((windowStyle & (long) checkStyle) == (long) checkStyle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Kernel32
|
public static class Kernel32
|
||||||
|
|||||||
Reference in New Issue
Block a user