Пример #1
0
        public CefWebView(string url, bool transparent = false)
        {
            _core          = new WebBrowser(this, new CefBrowserSettings(), url ?? "about:blank");
            _core.Created += new EventHandler(BrowserCreated);

            var windowInfo = CefWindowInfo.Create();

            windowInfo.SetAsPopup(IntPtr.Zero, null);
            windowInfo.Name = url;
            if (transparent)
            {
                windowInfo.TransparentPaintingEnabled = true;
                windowInfo.Width  = 500;
                windowInfo.Height = 500;
                //windowInfo.Style = WindowStyle.WS_POPUP | WindowStyle.WS_SIZEFRAME | WindowStyle.WS_VISIBLE;
                windowInfo.StyleEx = WindowStyleEx.WS_EX_COMPOSITED;
            }

            _core.Create(windowInfo);
        }
Пример #2
0
        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);

            if (DesignMode)
            {
                // if (!_handleCreated) Paint += PaintInDesignMode;
            }
            else
            {
                var windowInfo = CefWindowInfo.Create();
                windowInfo.SetAsChild(Handle, new CefRectangle {
                    X = 0, Y = 0, Width = Width, Height = Height
                });

                _core.Create(windowInfo);
            }

            _handleCreated = true;
        }