Ejemplo n.º 1
0
        private unsafe void PlatformConstruct()
        {
            int             x         = 0;
            int             y         = 0;
            WINDOW_STYLE    style     = 0;
            WINDOW_EX_STYLE styleEx   = 0;
            const bool      resizable = true;

            // Setup the screen settings depending on whether it is running in full screen or in windowed mode.
            //if (fullscreen)
            //{
            //style = User32.WindowStyles.WS_POPUP | User32.WindowStyles.WS_VISIBLE;
            //styleEx = User32.WindowStyles.WS_EX_APPWINDOW;

            //width = screenWidth;
            //height = screenHeight;
            //}
            //else
            {
                if (ClientSize.Width > 0 && ClientSize.Height > 0)
                {
                    int screenWidth  = GetSystemMetrics(SM_CXSCREEN);
                    int screenHeight = GetSystemMetrics(SM_CYSCREEN);

                    // Place the window in the middle of the screen.WS_EX_APPWINDOW
                    x = (screenWidth - ClientSize.Width) / 2;
                    y = (screenHeight - ClientSize.Height) / 2;
                }

                if (resizable)
                {
                    style = WS_OVERLAPPEDWINDOW;
                }
                else
                {
                    style = WS_POPUP | WS_BORDER | WS_CAPTION | WS_SYSMENU;
                }

                styleEx = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
            }
            style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;

            int windowWidth;
            int windowHeight;

            if (ClientSize.Width > 0 && ClientSize.Height > 0)
            {
                var rect = new RECT
                {
                    right  = ClientSize.Width,
                    bottom = ClientSize.Height
                };

                // Adjust according to window styles
                AdjustWindowRectEx(&rect, style, default, styleEx);
Ejemplo n.º 2
0
 public static unsafe HWND CreateWindowEx(WINDOW_EX_STYLE dwExStyle, string lpClassName, string lpWindowName, WINDOW_STYLE dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, SafeHandle hMenu = default, SafeHandle hInstance = default)
 {
     return(CreateWindowEx(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, null));
 }