public Window( WindowClass windowClass, Rectangle bounds, string windowName = default, User32.WS style = User32.WS.OVERLAPPED, User32.WS_EX extendedStyle = User32.WS_EX.DEFAULT, bool isMainWindow = false, Window parentWindow = default, IntPtr parameters = default, IntPtr menuHandle = default) { _windowClass = windowClass; if (!_windowClass.IsRegistered) { _windowClass.Register(); } Handle = _windowClass.CreateWindow( bounds, windowName, style, extendedStyle, isMainWindow, parentWindow?.Handle ?? default, parameters, menuHandle); }
public IntPtr CreateWindow( string windowName = null, User32.WS style = User32.WS.OVERLAPPED, User32.WS_EX extendedStyle = default, bool isMainWindow = false, IntPtr parentWindow = default, IntPtr parameters = default, IntPtr menuHandle = default) { return(CreateWindow( DefaultBounds, windowName, style, extendedStyle, isMainWindow, parentWindow, parameters, menuHandle)); }
public unsafe IntPtr CreateWindow( RECT bounds, string windowName = null, User32.WS style = User32.WS.OVERLAPPED, User32.WS_EX extendedStyle = default, bool isMainWindow = false, IntPtr parentWindow = default, IntPtr parameters = default, IntPtr menuHandle = default) { if (!IsRegistered) { throw new ArgumentException("Window class must be registered before using."); } IntPtr window = User32.CreateWindowExW( dwExStyle: extendedStyle, lpClassName: (char *)Atom, lpWindowName: windowName, dwStyle: style, X: bounds.X, Y: bounds.Y, nWidth: bounds.Width, nHeight: bounds.Height, hWndParent: parentWindow, hMenu: menuHandle, hInst: IntPtr.Zero, lpParam: parameters); if (isMainWindow) { MainWindow = window; } return(window); }
public static User32.WS_EX GetExtendedStyle(this IWin32Window window) { User32.WS_EX style = (User32.WS_EX)User32.GetWindowLong(Control.GetSafeHandle(window), User32.GWL.EXSTYLE); GC.KeepAlive(window); return(style); }
public unsafe IntPtr CreateWindow( RECT bounds, string windowName = null, User32.WS style = User32.WS.OVERLAPPED, User32.WS_EX extendedStyle = default, bool isMainWindow = false, IntPtr parentWindow = default, IntPtr parameters = default, IntPtr menuHandle = default) { if (!IsRegistered) { throw new ArgumentException("Window class must be registered before using."); } IntPtr window; if (Atom.IsValid) { window = User32.CreateWindowExW( dwExStyle: extendedStyle, lpClassName: (char *)Atom.ATOM, lpWindowName: windowName, dwStyle: style, X: bounds.X, Y: bounds.Y, nWidth: bounds.Width, nHeight: bounds.Height, hWndParent: parentWindow, hMenu: menuHandle, hInst: IntPtr.Zero, lpParam: parameters); } else { fixed(char *atom = _className) { window = User32.CreateWindowExW( dwExStyle: extendedStyle, lpClassName: atom, lpWindowName: windowName, dwStyle: style, X: bounds.X, Y: bounds.Y, nWidth: bounds.Width, nHeight: bounds.Height, hWndParent: parentWindow, hMenu: menuHandle, hInst: IntPtr.Zero, lpParam: parameters); } } if (window == IntPtr.Zero) { throw new Win32Exception(Marshal.GetLastWin32Error()); } if (!Atom.IsValid) { Atom = User32.GetClassLong(window, User32.GCL.ATOM); } if (isMainWindow) { MainWindow = window; } return(window); }