Пример #1
0
        public static Window Create(SW show = SW.SHOW, HWND parent = default(HWND))
        {
            var ms        = Assembly.GetEntryAssembly().GetModules();
            var hInstance = Marshal.GetHINSTANCE(ms[0]);

            var window = new Window(s_count++);

            var wc = new WNDCLASSEXW
            {
                cbSize        = (uint)Marshal.SizeOf(typeof(WNDCLASSEXW)),
                style         = CS.VREDRAW | CS.HREDRAW | CS.DBLCLKS,
                lpszClassName = window.m_className,
                lpfnWndProc   = window.Callback,
                hInstance     = hInstance,
                hCursor       = User32.LoadCursorW(default(HINSTANCE), IDC.ARROW),
            };
            var register = User32.RegisterClassExW(ref wc);

            if (register == 0)
            {
                return(null);
            }

            var hwnd = User32.CreateWindowExW(0, window.m_className, WINDOW_NAME, WS.OVERLAPPEDWINDOW,
                                              User32.CW_USEDEFAULT,
                                              User32.CW_USEDEFAULT,
                                              User32.CW_USEDEFAULT,
                                              User32.CW_USEDEFAULT,
                                              parent,
                                              IntPtr.Zero, hInstance, IntPtr.Zero);

            if (hwnd == IntPtr.Zero)
            {
                return(null);
            }

            window.m_hwnd = hwnd;

            window.Show(show);

            return(window);
        }
Пример #2
0
 public static extern uint RegisterClassExW(ref WNDCLASSEXW Arg1);