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 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); }