Exemple #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);
Exemple #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));
 }
    private unsafe void PlatformConstruct()
    {
        WINDOW_STYLE style      = 0;
        const bool   resizable  = true;
        const bool   fullscreen = false;

        // Setup the screen settings depending on whether it is running in full screen or in windowed mode.
        if (fullscreen)
        {
            style = WS_CLIPSIBLINGS | WS_GROUP | WS_TABSTOP;
        }
        else
        {
            style = WS_CAPTION |
                    WS_SYSMENU |
                    WS_MINIMIZEBOX |
                    WS_CLIPSIBLINGS |
                    WS_BORDER |
                    WS_DLGFRAME |
                    WS_THICKFRAME |
                    WS_GROUP |
                    WS_TABSTOP;

            if (resizable)
            {
                style |= WS_SIZEBOX;
            }
            else
            {
                style |= WS_MAXIMIZEBOX;
            }
        }

        int x = 0;
        int y = 0;
        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, false, WS_EX_APPWINDOW);

            windowWidth  = rect.right - rect.left;
            windowHeight = rect.bottom - rect.top;

            int screenWidth  = GetSystemMetrics(SM_CXSCREEN);
            int screenHeight = GetSystemMetrics(SM_CYSCREEN);

            // Place the window in the middle of the screen.WS_EX_APPWINDOW
            x = (screenWidth - windowWidth) / 2;
            y = (screenHeight - windowHeight) / 2;
        }
        else
        {
            x = y = windowWidth = windowHeight = CW_USEDEFAULT;
        }

        hWnd = CreateWindowEx(
            WS_EX_APPWINDOW,
            Application.WindowClassName,
            Title,
            style,
            x,
            y,
            windowWidth,
            windowHeight,